A dual-binding library for window.location.hash
Example
var hash = new Hash(window);
var someVal = hash.get('setting');
hash.set('setting', someVal);
var bound = hash.bind('setting')
.addListener(function onSettingChange(val) {
console.log('the setting is', val);
})
;
var bound = hash.bind('setting')
.setParse(parseInt)
.addListener(function onSettingChange(val) {
console.log('the setting is', val);
})
;
var bound = hash.bind('setting')
.setParse(parseInt)
.setDefault('42')
.addListener(function onSettingChange(val) {
console.log('the setting is', val);
})
;
hash.set('setting', 99);
bound.set(99);
MIT Licensed