Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //MyActions file:
- export const fooAction = createAction(
- '[Foo] Foo Action',
- props<{ foo: string }>()
- );
- export const barAction = createAction(
- '[Bar] Bar Action',
- props<{ bar: string }>()
- );
- //end
- //actions index file:
- import * as MyActions from '(path)/ngrx/my-actions';
- export {MyActions};
- // end
- //effects file:
- import { MyActions} from '(path to actions index file)
- ...
- export class MyEffects {
- constructor(public actions$: Actions) {}
- test1$ = createEffect(() =>
- this.actions$.pipe(
- ofType(MyActions.fooAction),
- switchMap(({ foo }) => EditActions.barAction)
- )
- );
- test2$ = createEffect(() =>
- this.actions$.pipe(
- ofType(MyActions.fooAction),
- withLatestFrom(this.store.select(selectCompanyId)),
- switchMap(
- ([{ foo }, id]: [{ foo: string }, number]) => EditActions.barAction
- )
- )
- );
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement