Skip to content

Instantly share code, notes, and snippets.

@jnv
Created October 26, 2018 10:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jnv/8952cecc36cec33e2e4bbf63a34631aa to your computer and use it in GitHub Desktop.
Save jnv/8952cecc36cec33e2e4bbf63a34631aa to your computer and use it in GitHub Desktop.
BakeryJS Example Component (helloworld.js)
const {boxFactory} = require('bakeryjs');
// Just a helper to throttle emitting
const {promisify} = require('util');
const timeout = promisify(setTimeout);
module.exports = boxFactory(
'helloworld',
{
provides: ['text'],
requires: [],
emits: ['text'],
aggregates: false,
},
async function(serviceProvider, value, emit) {
emit([{text: 'Hello world!'}]);
await timeout(230);
emit([{text: 'This is a bit longer text'}, {text: 'Ahoj světe!'}]);
await timeout(150);
emit([{text: 'This text is shorter'}, {text: 'Bonjour monde!'}]);
await timeout(200);
}
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment