Async

@react-state/store has native support of observables and promises like RxJs. In order to make action async add @Async() decorator on top of th function

Functions or getters should return observable or promise.

Example taken from sample application

 @Async()
 get progress(): any {
        return this.store.select(['checkbox'])
            .pipe(
                switchMap(state => iif(() => !!state,
                    interval(20).pipe(
                        takeUntil(timer(4000).pipe(
                            tap(_ => {
                                this.store.update(state => {
                                    state.set('disabled', false);
                                });
                            }))
                        )),
                    of(0)
                ))
            )
    }

Last updated