Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

replace mergeMap with switchMap, fixes #27 #60

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions docs/modules/Observable.ts.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ Added in v0.6.0

<h2 class="text-delta">Table of contents</h2>

- [Alternative](#alternative)
- [zero](#zero)
- [Alt](#alt)
- [alt](#alt)
- [Alternative](#alternative)
- [zero](#zero)
- [Applicative](#applicative)
- [of](#of)
- [Apply](#apply)
Expand Down Expand Up @@ -43,7 +43,7 @@ Added in v0.6.0
- [fromTask](#fromtask)
- [instances](#instances)
- [Alt](#alt-1)
- [Alternative](#alternative)
- [Alternative](#alternative-1)
- [Applicative](#applicative-1)
- [Apply](#apply-1)
- [Compactable](#compactable-1)
Expand All @@ -65,32 +65,32 @@ Added in v0.6.0

---

# Alternative
# Alt

## zero
## alt

Identifies an associative operation on a type constructor. It is similar to `Semigroup`, except that it applies to
types of kind `* -> *`.

**Signature**

```ts
export declare const zero: <A>() => Observable<A>
export declare const alt: <A>(that: () => Observable<A>) => (fa: Observable<A>) => Observable<A>
```

Added in v0.6.12

# Alt
Added in v0.6.0

## alt
# Alternative

Identifies an associative operation on a type constructor. It is similar to `Semigroup`, except that it applies to
types of kind `* -> *`.
## zero

**Signature**

```ts
export declare const alt: <A>(that: () => Observable<A>) => (fa: Observable<A>) => Observable<A>
export declare const zero: <A>() => Observable<A>
```

Added in v0.6.0
Added in v0.6.12

# Applicative

Expand Down
6 changes: 3 additions & 3 deletions src/Observable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import * as O from 'fp-ts/lib/Option'
import { pipe } from 'fp-ts/lib/pipeable'
import { Task } from 'fp-ts/lib/Task'
import { combineLatest, defer, EMPTY, merge, Observable, of as rxOf } from 'rxjs'
import { map as rxMap, mergeMap } from 'rxjs/operators'
import { map as rxMap, switchMap } from 'rxjs/operators'
import { MonadObservable1 } from './MonadObservable'

// -------------------------------------------------------------------------------------
Expand Down Expand Up @@ -107,7 +107,7 @@ export const of: Applicative1<URI>['of'] = rxOf
* @since 0.6.0
*/
export const chain: <A, B>(f: (a: A) => Observable<B>) => (ma: Observable<A>) => Observable<B> = f => ma =>
ma.pipe(mergeMap(f))
ma.pipe(switchMap(f))

/**
* Derivable from `Monad`.
Expand Down Expand Up @@ -152,7 +152,7 @@ export const alt: <A>(that: () => Observable<A>) => (fa: Observable<A>) => Obser
*/
export const filterMap = <A, B>(f: (a: A) => O.Option<B>) => (fa: Observable<A>): Observable<B> =>
fa.pipe(
mergeMap(a =>
switchMap(a =>
pipe(
f(a),
// tslint:disable-next-line: deprecation
Expand Down