Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ScalableJS/a87b51e0e4d3685c961d88e6f845bc72 to your computer and use it in GitHub Desktop.
Save ScalableJS/a87b51e0e4d3685c961d88e6f845bc72 to your computer and use it in GitHub Desktop.
var $ACTION = function (eventName) {
var SESSION_EVENT_NAME = 'MM_' + eventName;
var catchEvent = function (fn) {
var sessionEventValue = window.sessionStorage[SESSION_EVENT_NAME];
if (typeof fn == 'function' && sessionEventValue) {
fn(sessionEventValue)
}
delete window.sessionStorage[SESSION_EVENT_NAME];
};
var postpone = function (value) {
window.sessionStorage[SESSION_EVENT_NAME] = value;
};
return {
catchEvent: catchEvent,
postpone: postpone
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment