We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
A store with two counters:
export interface CounterStoreState extends State { counter1: number; counter2: number; } @Injectable() @StoreConfig({ name: 'counter' }) export class CounterStore extends Store<CounterStoreState> { constructor() { super({ counter1: 0, counter2: 0, }); } }
AppComponent
export class AppComponent { constructor(readonly counterStore: CounterStore) { //Once counter1 increases, update counter2, synchronously counterStore._select((state) => { if (state.counter1 !== state.counter2) { counterStore.update({ counter2: state.counter1 }) } }).subscribe(); //Print counter1, counter2 counterStore._select((state) => { return `counter1: ${state.counter1} counter2: ${state.counter2}`; }).subscribe(console.log); counterStore.update({ counter1: 1 }); } }
Print output:
counter1: 0 counter2: 0 counter1: 1 counter2: 1 counter1: 1 counter2: 0
Conclusion The store will emit an old value in the end, because of the nested update() call
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Description
A store with two counters:
AppComponent
Print output:
Conclusion
The store will emit an old value in the end, because of the nested update() call
The text was updated successfully, but these errors were encountered: