Skip to content

Instantly share code, notes, and snippets.

@kmaraz
Created December 6, 2019 23:16
Show Gist options
  • Save kmaraz/b03e361aefa627fc43debdccf6b355a8 to your computer and use it in GitHub Desktop.
Save kmaraz/b03e361aefa627fc43debdccf6b355a8 to your computer and use it in GitHub Desktop.
@Injectable({
providedIn: 'root'
})
export class ThingsEffects {
fetchThings$ = createEffect(() => this.actions$.pipe(
ofType(ThingsActions.fetchThings),
switchMap(() => this.api.things.fetch()
.pipe(
map((data) => ThingsActions.update(data.items))
))
));
constructor(
private actions$: Actions<ThingsActions.All>,
private api: API
) { }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment