Skip to content

Instantly share code, notes, and snippets.

@milleraundra
Created September 1, 2017 17:38
Show Gist options
  • Save milleraundra/0131890ae008443cd075c0e927f92179 to your computer and use it in GitHub Desktop.
Save milleraundra/0131890ae008443cd075c0e927f92179 to your computer and use it in GitHub Desktop.
You can use the from creator and the mergeMap operator to merge an observable into the effect's Action stream.
Using your example:
@Effect() addPeopleStart$ = this.actions$
.ofType( PersonActionTypes.ADD_PERSON_LIST_START )
.switchMap(
( payload ) => {
return this.personService.getPeople();
}
)
.mergeMap(
( result: string[] ) => {
return Observable.from([ new AddPersonList( result ), new AddPersonListComplete() ]);
}
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment