This ia an extension module the Mono web framework. The Event module is used by other Mono modules (like the layout module) to add the Mono event support in their configurations.
This module is built only on top of the Mono client library (M.js) and has no further dependencies.
Module that need Mono event support in their configurations need to:
- add this module as a dependency in their
mono.jsondescriptor (example):
{
…
"dependencies": [
…
"github/jillix/events/v0.1.1",
…
],
…
}- require this module in their client scripts (example):
var Events = require('github/jillix/events');- somewhere in the code (most often seen in the initialization function) call the
Eventsfunction in the scope ofthismodule, passing it the configuration (example):
var Events = require('github/jillix/events');This module extends a module's configuration with the listen key.
{
"listen": {
"miid1": {
"event1FromMiid1": [ … ],
"event2FromMiid1": [ … ]
},
"miid2": {
"eventFromMiid2": [ … ]
}
}
}where:
- listen: is an object that has as keys the
miid's of the module to listen to and values event objects - event object: is an objectt that has as keys the event names emitted by a module and as values action arrays
- action array: is an array of action objects to take (in order) when the particular event is received
- acction object: has as key one of:
handler,eventhandleractions can have as value either a string (a function name to be called) or an object if fixed parameters need to be passed to the handler function (see example below)emitactions have as value a string (an event to be emitted)
{
"listen": {
"miid": {
"eventFromMiid": [
{ "handler": "aFunctionInMiid1" },
{ "handler": { "name": "anotherFunctionInMiid1", "args": ["fixed argument"] } },
{ "emit": "anotherEvent" }
]
}
}
}- transferred module to the new jxMono organization
- updated Utils to
v0.2.0
- Updated to
[email protected]
- Updated to
[email protected]
- Updated Utils to
v0.1.2
- Added Utils as dependency
- The module can not uninit events (remove handlers) if an extra
trueargument is passed to the library:Events.call(self, self.config, true). The module configuration will be changed to store the function handlers.
- Add event even the function is not found when the event is added. The function can be declared latter.
- Fixed broken
hasOwnPropertythat usedreturninstead ofcontinue
- Fixed counter declaration in for loops: replaced
iwithii
- added
if (!obj.hasOwnProperty(key)) return;to object for loops
- fixed IE8 compatibility by removing all
for (var i in ...)expressions - fixed simple event version to support global namespaced functions:
{
"listen": {
"myMiid": {
"myEvent": "simple_handler_call"
}
}
}
- added namespaced function support for handlers
TODO
TODO