Skip to content

Instantly share code, notes, and snippets.

@wojtek1150
Created June 1, 2018 07:40
Show Gist options
  • Save wojtek1150/7a37a586709aed1697c2ff808661a4e3 to your computer and use it in GitHub Desktop.
Save wojtek1150/7a37a586709aed1697c2ff808661a4e3 to your computer and use it in GitHub Desktop.
@Injectable()
export class UsersEffect {
constructor(
private actions$: Actions,
private usersService: UsersService
) {}
@Effect()
loadUsers$ = this.actions$
.ofType(usersActions.LOAD_USERS)
.pipe(switchMap(() => {
return this.usersService.getUsers().pipe(
map((users: Users.List) => new usersActions.LoadUsersSuccess(users)),
catchError(error => of(new usersActions.LoadUsersFail(error)))
);
})
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment