How to use the mobx-utils.toStream function in mobx-utils

To help you get started, we’ve selected a few mobx-utils 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 phiresky / backchannel-prediction / evaluate / plot / util.ts View on Github external
export function throttleGet(time: number, getter: () => T): T {
    if(tcache.has(getter)) {
        return tcache.get(getter)!.current;
    }
    const ob = Rx.Observable.from(mu.toStream(getter));
    const ob2 = ob.debounceTime(time); //.merge(ob.delay(time).sampleTime(time));
    const v = mu.fromStream(ob2, mobx.untracked(getter));
    tcache.set(getter, v);
    return v.current;
}