A dual-binding library for window.location.hash
Example
var Hash = require('hashbind');
var Result = require('rezult');
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(Result.lift(parseInt))
.addListener(function onSettingChange(val) {
console.log('the setting is', val);
})
;
var bound = hash.bind('setting')
.setParse(Result.lift(parseInt))
.setDefault('42')
.addListener(function onSettingChange(val) {
console.log('the setting is', val);
})
;
hash.set('setting', 99);
bound.set(99);
have them thrown):
bound.set('XXX', function setDone(err, str, val) {
console.error(err);
});
MIT Licensed