Created
November 11, 2019 10:51
-
-
Save CharGrnmn/727066bef0c828644d6af5185cd32555 to your computer and use it in GitHub Desktop.
Posts Effects Example, for use of hot observables
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @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