Hullo JS
Search…
ofHistory
import { history } from '@hullo/browser'
Adapter for window.history for Hullo. ofHistory is duplex meaning it is both observable and observer. Observable part allows reacting to history state / url observation. Observer part allows manipulation of history.
1
import { ofHistory } from '@hullo/browser';
2
import { createBrowserHistory } from 'history';
3
​
4
const history = createBrowserHistory({});
5
​
6
const history$ = ofHistory<{ q: number }>(history);
7
​
8
history$
9
.subscribe({
10
next({ state, pathname }) {
11
console.log({ state, href: pathname });
12
}
13
});
14
​
15
history$.next({ pathname: '/path' });
Copied!
Last modified 2yr ago
Copy link