Skip to content

Instantly share code, notes, and snippets.

@CharGrnmn
Created November 11, 2019 10:51
Show Gist options
  • Select an option

  • Save CharGrnmn/727066bef0c828644d6af5185cd32555 to your computer and use it in GitHub Desktop.

Select an option

Save CharGrnmn/727066bef0c828644d6af5185cd32555 to your computer and use it in GitHub Desktop.
Posts Effects Example, for use of hot observables
@Effect() loadPosts$ = this.dataPersistence.fetch(
PostsActionTypes.LoadPosts,
{
run: (action: LoadPosts, state: PostsPartialState) => {
return this.postsService.getPosts().pipe(
map((posts: Post[]) => new PostsLoaded(posts))
);
},
onError: (action: LoadPosts, error) => {
console.error('Error', error);
return new PostsLoadError(error);
}
}
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment