Created
May 27, 2020 08:49
-
-
Save Armenvardanyan95/7be860fd04591f076486a85bf9ceac51 to your computer and use it in GitHub Desktop.
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
| const loadData = createAction('[Home Page] Load Data'); | |
| const loadDataSuccess = createAction( | |
| '[Home Page] Load Data', | |
| props<{payload: object}>(), | |
| ); | |
| const _dataReducer = createReducer( | |
| {}, | |
| on(loadDataSuccess, (state, {payload}) => ({...state, ...payload})), | |
| ); | |
| @Injectable() | |
| export class DataEffects { | |
| loadData$ = createEffect(() => this.actions$.pipe( | |
| ofType(loadData), | |
| mergeMap(() => this.dataService.getData().pipe( | |
| map(payload => loadDataSuccess({payload})), | |
| )), | |
| )); | |
| constructor( | |
| private readonly actions$: Actions, | |
| private readonly dataService: DataService, | |
| ) {} | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment