mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-17 12:16:38 +08:00
15 lines
515 B
TypeScript
15 lines
515 B
TypeScript
/// <reference path="hasher.d.ts" />
|
|
|
|
//handle hash changes
|
|
function handleChanges(newHash: any, oldHash: any) {
|
|
console.log(newHash);
|
|
}
|
|
|
|
hasher.changed.add(handleChanges); //add hash change listener
|
|
hasher.initialized.add(handleChanges); //add initialized listener (to grab initial value in case it is already set)
|
|
hasher.init(); //initialize hasher (start listening for history changes)
|
|
|
|
hasher.setHash('foo'); //change hash value (generates new history record)
|
|
|
|
hasher.prependHash = '!'; //default value is "/"
|