Skip to content

Instantly share code, notes, and snippets.

@jnv
Created Oct 26, 2018
Embed
What would you like to do?
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