Soluto / shisell-js

A service agnostic library for building immutable scoped analytic event dispatchers with extra data, identities and lazy filters.
MIT License
41 stars 3 forks source link

Create stateful dispatchers #10

Open AsafRosen opened 9 years ago

AsafRosen commented 9 years ago

Allow creating stateful dispatchers so that a change in the stateful dispatcher will propegate to all children of the stateful dispatcher.

e.g.

var rootDispatcher = new StatefulDispatcher(\*...*\); 

var childDispatcher = rootDispatcher.createScoped("SomeScreen"); 

rootDispatcher.setIdentity("User ID", "123"); 
rootDispatcher.setDispatchMethod(function(event) { console.log(event) } ); 

childDispatcher.dispatch("View"); // Will write to the console view event with User ID: 123

This will allow apps to create a root dispatcher and set its' behavior/dispatching method.

Yshayy commented 9 years ago

I think it's a property of the state (mutability), not the the dispatcher