1.6.0 • Published 4 years ago

future-event v1.6.0

Weekly downloads
1
License
MIT
Repository
-
Last release
4 years ago

FutureEvent

A simple, tiny utility class for promising a future event will occur, allowing you to await it. For instance:

async function test() {
  /** Promise an event will happen eventually. */
  const inFiveSeconds = new FutureEvent();

  /** Fire FutureEvent.ready() after 5s. */
  setTimeout(() => inFiveSeconds.ready(), 5e3);
  
  console.log('⏱️  Waiting for event...');
  await inFiveSeconds;
  console.log('✅  Done!');
}

test();

Will print ⏱️ Waiting for event..., wait 5 seconds until the event fires (non-blocking), and then print ✅ Done! (Run yourself with node example/ in the root directory.)

1.6.0

4 years ago

1.5.0

4 years ago

1.1.0

4 years ago

1.0.0

4 years ago