Last active
April 8, 2018 04:17
-
-
Save JemiloII/82f3b4076ec0988558c4 to your computer and use it in GitHub Desktop.
This is just the beginning of the native storage promise system
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Storage.prototype._setItem = Storage.prototype.setItem; | |
Storage.prototype.setItem = function(key, value, type, name) { | |
var eventName = name || 'storage'; | |
var eventObject = { | |
"target": window, | |
"type": "storage", | |
"bubbles": false, | |
"cancelable": false, | |
"key": key, | |
"oldValue": type.getItem(key), | |
"newValue": value, | |
"url": window.location.href, | |
"storageArea": type | |
}; | |
this._setItem(key, value); | |
window.dispatchEvent(new StorageEvent(eventName, eventObject)); | |
}; | |
window.addEventListener('storage', function(e){ document.querySelector('body').innerHTML = e.newValue;}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment