How to use the @politie/sherlock.constant.unresolved function in @politie/sherlock

To help you get started, we’ve selected a few @politie/sherlock examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github politie / sherlock / extensions / sherlock-utils / src / state.spec.ts View on Github external
it('should transfer unresolved state', () => {
        const from$ = constant.unresolved();
        const to$ = atom(123);
        copyState(from$, to$);
        expect(to$.resolved).to.be.false;
    });
github politie / sherlock / extensions / sherlock-utils / src / state.spec.ts View on Github external
it('should support lifecycle options', () => {
        const a$ = atom(0);
        const unresolved$ = constant.unresolved();
        const error = new Error('this is not good!');
        const d$ = a$.derive(v => {
            switch (v) {
                case 0: return 42;
                case 1: throw error;
                default: return unresolved$.get() + 42;
            }
        });
        const until = atom(false);
        const target$ = atom.unresolved();

        syncState(d$, target$, { until });

        expect(target$.value).to.equal(42);

        a$.set(1);