A bus, a handler registered on it, and a service that emits: one event-emitter edge.
(dir: string)
| 38 | |
| 39 | /** A bus, a handler registered on it, and a service that emits: one event-emitter edge. */ |
| 40 | function fixture(dir: string): void { |
| 41 | write(dir, 'package.json', JSON.stringify({ name: 'app' })); |
| 42 | write(dir, 'src/bus.js', "const { EventEmitter } = require('events');\nconst bus = new EventEmitter();\nmodule.exports = { bus };\n"); |
| 43 | write(dir, 'src/handlers.js', "const { bus } = require('./bus');\nfunction onSaved(doc) { return doc; }\nbus.on('saved', onSaved);\nmodule.exports = { onSaved };\n"); |
| 44 | write(dir, 'src/service.js', "const { bus } = require('./bus');\nfunction save(doc) { bus.emit('saved', doc); return doc; }\nmodule.exports = { save };\n"); |
| 45 | } |
| 46 | |
| 47 | /** A second event on the bus: the edit that makes a sync rebuild the synthesized edges. */ |
| 48 | function addRemovedEvent(dir: string): void { |