singelton-app

1.0.1 • Public • Published

singelton-app

With this very simple module you can create a singelton application instance (global application instance) that can be required/imported by other modules in the same application, so that they all share the same instance of the application module.

How to use

All you need to do is to require the singelton-app from your main module (for example app.js) and then extend it with your application functions:

app.js

var app = require('singelton-app');

app.extend({

  initialize: function () {
    console.log( 'initialize function' );
  },

  sayHello: function () {
    console.log( 'Hello!' );
  }

});

app.initialize();

Then you can access the extended functions of the singelton application from any project module with:

someModule.js

var app = require('singelton-app');

exports.someFunction = function() {
    app.sayHello();
});

Dependents (0)

Package Sidebar

Install

npm i singelton-app

Weekly Downloads

1

Version

1.0.1

License

ISC

Last publish

Collaborators

  • mw.localizedirect.com