js-facade-factory
npm install --save facade-factory
Demo
Releases:
A way to create facades that are guaranteed to have only the methods listed in their descriptions. This is a useful collaboration or organizational tool.
Sample usage:
In a shared file / module, describe the facade that will be used by multiple imlementations. The facade is described using key value pairs. The keys are the method names, and the values are the descriptions of the functionality.
var playerFacade = play: 'method to play movies' stop: 'method to stop movies';
Create a facade implelemntation. Helper methods and fields may be used and will be functional, but they will not be exposed as part of the facade; they are essentially private.
var htmlPlayer = time: 0 { ++thistime; this; return this; } { console; return this; } { console; };
Now create the facade using its description and implementation
var player = playerFacade htmlPlayer;
Use it:
player;
Now you can use the same code that relies on a player
for different types of players in different environments.
// Create a flash playervar player = playerFacade flashPlayer; // Or create an html playervar player = playerFacade htmlPlayer; // Use the player without caring which one you have.player;
Contributors
Changelog
- 0.1.0 - 2017 Feb 06 - Publishing on NPM
- 0.0.3 - 2013 Oct 15 - Support for AMD
- 0.0.2 - 2013 Jan 10 - Support for properties
- 0.0.1 - 2012 Nov 09 - Initial release