Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
@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