--
You received this message because you are subscribed to the Google Groups "LoopbackJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to loopbackjs+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
in my server.js I did thisif (require.main === module) {// app.start();var server = require('socket.io')(app.start()); // I replace the app.start() with this}
--
You received this message because you are subscribed to a topic in the Google Groups "LoopbackJS" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/loopbackjs/6qpQwggf2_c/unsubscribe.
To unsubscribe from this group and all its topics, send an email to loopbackjs+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Why not add boot script with something like following:// boot/io.jsmodule.exports = function(app) {app.on('started', function() {require('./io')(app, app.io);});}
thanks for this - it works ... but .. ;)how do I refer to app.io in my model ? I am wanting to emit a message on an update, so I am hooking into the afterSave()module.exports = function (Salesrep) {Salesrep.afterSave = function(next) {app.io.to("data:salesrep").emit( "afterUpdate", { body: this } )}
module.exports = function (Salesrep) {
Salesrep.afterSave = function(next) {
Salesrep.app.io.to("data:salesrep").emit( "afterUpdate", { body: this } )
}
...
}
module.exports = function (Salesrep) {
Salesrep.on('attached', function() {
var app = Salesrep;
Salesrep.afterSave = function(next) {
app.io.to("data:salesrep").emit( "afterUpdate", { body: this } )
}
}
...
})
}