state-switch
Version:
State Switch is a Change Monitor/Guarder for Async Actions.
14 lines • 563 B
JavaScript
import { firstValueFrom, from, } from 'rxjs';
import { filter,
// eslint-disable-next-line import/extensions
} from 'rxjs/operators';
const waitForSelector = async (stream$, selector) => {
const future = firstValueFrom(stream$.pipe(filter(selector)));
return future.then(() => undefined);
};
const waitForMachineState = async (interpreter, state) => {
const selector = (x) => x.value === state;
return waitForSelector(from(interpreter), selector);
};
export { waitForSelector, waitForMachineState, };
//# sourceMappingURL=wait-for-selector.js.map