realar-project / realar

5 kB Advanced state manager for React
MIT License
45 stars 0 forks source link

low: promise property to signal #52

Closed betula closed 3 years ago

betula commented 3 years ago
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...

betula commented 3 years ago

"promise" property implemented in 0.6.0

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