A simple javscript eventing library.
Get a property.
key
(String) - Name of property
Example
var name = Shindig.get('name');
Set a property and fire corresponding mutation event.
key
(String) - Name of propertyvalue
(mixed) - Value of propertysilent
(Boolean) - Bypass the mutation event
Example
Shindig.on('create:name', function (value) {
console.log(value); // Tony Starks
});
Shindig.on('change:name', function (values) {
console.log(value.old) // Tony Starks
console.log(value.new) // Iron Man
});
Shindig.set('name', 'Tony Starks');
Shindig.set('name', 'Iron Man');
Set a property and fire corresponding mutation event.
key
(String) - Name of propertysilent
(Boolean) - Bypass the mutation event
Example
Shindig.on('delete:name', function (value) {
console.log(value); // Tony Starks
});
Shindig.unset('name', true); // Will not fire event
Fire an event
evt
(String) - Name of eventdata
(mixed) - Data to pass to listener
Example
Shindig.fire('welcome', {
first: 'Tony',
last: 'Stark'
});
Listen for an event.
evt
(String) - Name of eventcallback
(Function) - Function to fire when event is called.context
(mixed) - Context that should be used when calling callback
Example
Shindig.on('welcome', function (name) {
console.log('Welcome ' + name.first); // Welcome Tony
});
Remove event listener
evt
(String) - Name of event
Example
Shindig.off('welcome');