-
Notifications
You must be signed in to change notification settings - Fork 6
Home
@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 _/
If you are not interested in the first emitted value, you should be able to use the skip operator:
store.select(...).skip(1)...
https://stackoverflow.com/questions/38953506/ngrx-store-ignore-first-emitted-value
const values: Partial<FirestoreDoc> = {
id: reference.key != null ? reference.key : ""
};
https://basarat.gitbooks.io/typescript/docs/promise.html
function doAsyncTask() {
var promise = new Promise((resolve, reject) => {
setTimeout(() => {
console.log("Async Work Complete");
if (error) {
reject();
} else {
resolve();
}
}, 1000);
});
return promise;
}
Also known as the ternary operator
Test ? expr1 : expr2;
- Test: Conditional expression
- expr1: Value returned if the condition is true
- expr2: Value returned if the condition is false
id: reference.key != null ? reference.key : '',
aa bb cc