await-signal
A simple promise-based signal system for running async tasks.
Installation
npm install await-signal
Usage
in browser
let traffic = 'stop' button { trafficstate = buttonclassName = buttonclassName === 'stop' ? 'pass' : 'stop'}
{ super0 thispanel = document } { thispanelinnerHTML = ++thisstate % 10 }const c0 = 'clock0'const c1 = 'clock1'const c2 = 'clock2' { await c1 c2 await c1 } ;{ await c0 await c1 };
SpriteAnimator.generateAnimation creates a signaling object.
let animation requestID start{ ifrequestID animation = SpriteAnimator animation blockstylebackgroundColor = 'red' animation animation requestID = } pause{ ifanimation animation } play{ ifanimation animation }
API
new Signal(initState)
Initialize a signal with a state.
const mySignal = 0
while(theState)
Return a promise that pendings when the signal state is theState.
{ const signal = true let i = 0const timer = await signal console //5 }
until(theState)
Return a promise that pendings when the signal state is not theState.
{ const signal = 0 const timer = let states = await signal console //0,1,2,3,4,5 }
License
MIT