A window history no config router.
npm install @devinle/radar
// In your script
import { radar } from '@devinle/radar';
// Make a callback function
const callback = (data) => { console.log(data); };
// Data Signature within callback is as follows
data = {
from: 'from/page/url,
to: 'to/page/url'
};
// Register a callback with the radar-change event
// This event will receive data
radar.on('radar-change', callback);
// Remove a specific callback from the radar-change
radar.off('radar-change', callback);
All links delegate to the body and will make a request to the window pushState.
<a href="/url/here">A Link</a>
To avoid calling the window pushState function, apply the radar-ignore class to a link.
<a href="/url/here" class="radar-ignore">A Link</a>
The body is bound to the radar.go method and all links clicked within the body will call this API method unless it contains the ignore class.
yarn run test