Skip to content
tja4472 edited this page Jan 20, 2018 · 7 revisions

@aph5nt you are not thinking reactive enough

onClick$ = new Subject();

constructor(private _store: Store) { this.onClick$ .withLatestFrom(this._store) .subscribe(([data, state]) => { // do whatever you want here }); } <button (click)="onClick$.next({ foo: 'bar', baz: $event })">click common use-case for this is when you map these handlers to ngrx actions, merge them and subscribe them to your store, which means that clicking button will essentially dispatch an action to the store, see #173 (comment)>

https://github.com/ngrx/store/issues/296#issuecomment-291780143

/* Best practice is to provide the user as part of the payload as mentioned instead of selecting it from the state in the effect. This keeps the Effect pure and easier to test. You can also write a selector that composes the two pieces of data together for your action. https://github.com/ngrx/platform/issues/496#issuecomment-337781385 */

Clone this wiki locally