-
Notifications
You must be signed in to change notification settings - Fork 2
interface Fiber
ben hockey edited this page Dec 25, 2011
·
2 revisions
Fibers are the way to apply code that extends the core functionality of the Kernel. There are a number of extension points available and the simplest way to apply code that uses these extension points is to encapsulate that code in a fiber.
A fiber must have an id
and implement two functions:
-
init
is a function that is passed the instance of the kernel that the fiber is being added to. Fiber initialization should be synchronous and the return value is ignored. -
terminate
is called to give the fiber a chance to cleanup when the kernel is destroyed.
The recommended way to add a fiber is via a Twine instance's addFiber
method.
var container = new Twine();
container.addFiber({
id: 'example',
init: function (kernel) {
// TODO: show an example
},
terminate: function () {
// TODO: show an example
}
});