1.0.5 • Published 8 years ago

molecule-singleton v1.0.5

Weekly downloads
-
License
WTFPL
Repository
-
Last release
8 years ago

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.