Thursday, June 28, 2012

Mootools Class in NodeJS global context - Second Approach

In my last article here, I described how to load Mootools class in NodeJS global context. What if I do not want to make use of include to load the class, is there a way I can still do it with require. So, lets rewrite the program, and check how to do it

Application.js
(function(){
 
var Application = this.Application = new Class(
{
    Implements: [process.EventEmitter],
    initialize: function()
    {
        console.log("App initialize");
    },
    compute: function()
    {
        console.log("App compute");
        this.emit("done");
    }
});
 
})();

So, now the main file contains the code as below

Server.js
require('./mootools');
require('./Application');
 
var app = new Application();
app.on("done", function() { console.log("App done"); });
app.compute();

Hope this will solve !

3 comments:

  1. Well, it would be better if you'll enlarge that. I am curious to get more materials on the topic.

    ReplyDelete
  2. Thank you for adding these tips here. That is the think I do need now. I would like to ask you to make your description more detailed, so I could follow it.

    ReplyDelete