Skip to content

Instantly share code, notes, and snippets.

@normanzb
Last active August 29, 2015 14:20
Show Gist options
  • Save normanzb/38ca5a08d10074ff2351 to your computer and use it in GitHub Desktop.
Save normanzb/38ca5a08d10074ff2351 to your computer and use it in GitHub Desktop.
Get value from state object
!function(){
// make sure there is et object
window.et = window.et || {};
// make sure there is et.state array
window.et.state = window.et.state || [];
var state = window.et.state;
// push a callback function into the array, once state object is instantiated,
// the callback will be called, and then you will be able to use those extended APIs
// such as get, put... etc...
state.push(null, function(){
// call get() to get multiple values at once
state.get('user.market', 'user.something', 'user.somethingelse').then(function(values){
console.log(values)
// do rest of the jobs here
});
})
}();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment