realar-project / realar

5 kB Advanced state manager for React

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

low: promise property to signal

betula opened this issue · comments

const { signal, loop } = require('realar');

const a = signal();
const b = signal();
const c = signal();

loop(async () => {
    await a; console.log('a ready');
    await b; console.log('b ready');
    await c; console.log('c ready');
    
    // possible syntax
    // const [pa, pb, pc] = [a.promise, b.promise, c.promise];
    // await pa;
    // await pb;
    // await pc;
    // console.log('ready');
});

a();
b();
c();

https://runkit.com/betula/60572b6307e748001a619912

Or maybe make another type of call

a.safe();
b.safe();
c.safe();

No... first suggest was better...

"promise" property implemented in 0.6.0

  const [pa, pb, pc] = [a.promise, b.promise, c.promise];