Skip to content

dxprog/molecule-singleton

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

A singleton pattern built on moleculejs

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published