-
Notifications
You must be signed in to change notification settings - Fork 145
Writing a Module
Kamal Kishor Joshi edited this page Mar 4, 2015
·
3 revisions
Say you want to write a module named foo.
- First, fork and check out the repository. Set it up on your machine using tools/install.sh
- Create a folder foo in the root
- If your module has server-side code, create a file foo/foo.js with the content
module.exports = function(core, config) { ... }. This function will be called when Scrollback starts up, and is the point of entry to your module. In /index.js, add your plugin to the list. - If your plugin has client-side code, create a file foo/foo.js with the content
module.exports = function(core, config) { ... }. This function will be called when Scrollback loads, and is the point of entry to your module. In /client.js, require() your plugin. - Write unit test for your module using mocha and and add the test file to test/test.js. see testing
Most of the work is done by attaching handlers to the core event dispatcher.
core.on('text', function(textAction, next) {
/* Do your work here */
next();
}, prio);core.emit('text', textAction, callback);core.on('text-dn', function(textAction, next) {
/* Do your work here */
next();
}, prio);core.emit('text-up', textAction, callback);core.on('navigate', function(navigationState, next) {
/* Do your work here */
next();
}, prio);