UNPKG

@applicaster/zapp-react-native-ui-components

Version:

Applicaster Zapp React Native ui components for the Quick Brick App

24 lines (19 loc) 792 B
import { ReplaySubject } from "rxjs"; import { pairwise, filter, first } from "rxjs/operators"; // we are interested in last 2 events, because we wait transition from <false> to <true> const screenRevealManagerSubject$ = new ReplaySubject<boolean>(2); export const emitScreenRevealManagerIsReadyToShow = () => { screenRevealManagerSubject$.next(true); }; export const emitScreenRevealManagerIsNotReadyToShow = () => { screenRevealManagerSubject$.next(false); }; export const waitUntilScreenRevealManagerIsReady = () => { return screenRevealManagerSubject$.pipe( pairwise(), // emit consecutive pairs: [prev, curr] filter( ([previousIsReady, currentIsReady]) => !previousIsReady && currentIsReady ), // detect transition from not_ready to ready first() ); };