Learn about our RFC process, Open RFC meetings & more.Join in the discussion! »

jqb-lifecycle

0.0.1 • Public • Published

jqb-lifecycle


Utility library to manage the life cycle of a list of objects.

NOTE: this module works fine with PoliteJS Workspace


Simple Application Lifecycle

// generic app  prototype
var GenericModuleClass = {
    init: function(config) {
        this.config = config;
    },
    start: function() {
        console.log(this.config);
    },
    stop: function() {
        this.config = undefined;
    }
}

// you app is composed with many modules
// (extensions of the generic module class)
var instances = [
    Object.create(Module1Class),
    Object.create(Module2Class),
    Object.create(Module3Class)
];

Code above represents a classic Javascript app where different responsibilities are coded into specific modules.

At the Application level you may need a simple way to initialise each modules, start them up and even dispose them:

var Lifecycle = require('jqb-lifecycle');

// start lifecycle
Lifecycle.start(instances, {
  foo:'faa'
});

// ... do your app ...

// end lifecycle
Lifecycle.stop(instances);

Install

npm i jqb-lifecycle

DownloadsWeekly Downloads

1

Version

0.0.1

License

MIT

Last publish

Collaborators

  • avatar