spec.md 1.2 KB

Request response idea:

State changes

Get a state controller , on state change it will inform the listeners trough eventual

context

.channel('state')
.on('core-installer:installed',() => {

})

Module gets loaded, and request

Whats the time? context.call("clock:time",(res) {

// Any module using time will answer this

}); context.on("clock:time",(res) {

res(new Date()); // Will continue to next thing 

});

Event flow:

Reason why this can happen in the control event flow

Contexts are only allowed to send messages on their behalf:

Consider the module 'clock':
    context.emit("time") -> will emit "clock:time"
    context.emit("core-installer:installed") -> will emit "clock:core-installer:installed"

Other module: expect a module named "clock" to send time
    context.on("clock:time",function(args) {
        var [time] = args;
        console.log("Clock sent: " + time);

    });

Conclusion:

    we cannot allow a module named 'clock' to fire events for core-installer

How will modules call other modules methods

Since we can't send events to specific modules we can use the regular way:
    context.with("clock").do((clock) => {
        clock.time();
    })
    var ret = context.call("module-name:method",1,2,3);