molecule-singleton

1.0.5 • Public • Published

Build Status

#molecule-singleton

A library for building and managing singletons built on moleculejs.

##Example:

// MySingleton.js
import Singleton from 'molecule-singleton';

export default Singleton({
  property: '',
  setProperty(prop) {
    this.property = prop;
  }
});

// ExecutedFirst.js
import MySingleton from './MySingleton.js';
MySingleton.setProperty('hey!');

// ExecutedNext.js
import MySingleton from './MySingleton.js';
console.log(MySingleton.property); // "hey!"

Singleton extends Molecule, so you can use this as a drop in replacement. The difference between the two is that Molecule will return a constructor, whereas Singleton returns an instance of the object. Check out the moleculejs repository for more information.

Readme

Keywords

none

Package Sidebar

Install

npm i molecule-singleton

Weekly Downloads

2

Version

1.0.5

License

WTFPL

Last publish

Collaborators

  • dxprog