Skip to content

Instantly share code, notes, and snippets.

@rainerhahnekamp
Last active August 12, 2021 12:44
Show Gist options
  • Save rainerhahnekamp/abd8cee442fe2e30cdc75808fbae8c4c to your computer and use it in GitHub Desktop.
Save rainerhahnekamp/abd8cee442fe2e30cdc75808fbae8c4c to your computer and use it in GitHub Desktop.
@Injectable()
export class CustomerEffects {
private baseUrl = 'https://local.eternal.com/api/customer';
constructor(
private actions$: Actions,
private http: HttpClient,
private router: Router
) {}
loadCustomers$ = createEffect(() =>
this.actions$.pipe(
ofType(CustomerActions.load),
switchMap(() => this.http.get<Customer[]>(this.baseUrl)),
map(customers => CustomerActions.loaded({ customers }))
)
);
// addCustomer$, updateCustomer$, removeCustomer$...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment