First of all -- fantastic package!
I was just wondering -- do you have any example documentation on how to use rlite without hash-based routing? For example, I'd like to be able to go to https://myApp/MyRoute rather than https://myApp/#myRoute
I got it working doing this:
history.pushState = ( f => function pushState(){
var ret = f.apply(this, arguments);
window.dispatchEvent(new Event('pushstate'));
window.dispatchEvent(new Event('locationchange'));
return ret;
})(history.pushState);
history.replaceState = ( f => function replaceState(){
var ret = f.apply(this, arguments);
window.dispatchEvent(new Event('replacestate'));
window.dispatchEvent(new Event('locationchange'));
return ret;
})(history.replaceState);
window.addEventListener('popstate',()=>{
window.dispatchEvent(new Event('locationchange'))
});
(location change example taken from here )
Then defining my routes
Then using this to hook into the custom event.
function processNoHash() {
// Do something useful with the result of the route
console.log(window.location.pathname);
document.body.textContent = route(window.location.pathname);
}
window.addEventListener('locationchange', processNoHash);
processNoHash();
It seems to work well, but I was wondering if there was a different recommended approach, and if perhaps an example could be added to the readme.
First of all -- fantastic package!
I was just wondering -- do you have any example documentation on how to use rlite without hash-based routing? For example, I'd like to be able to go to https://myApp/MyRoute rather than https://myApp/#myRoute
I got it working doing this:
(location change example taken from here )
Then defining my routes
Then using this to hook into the custom event.
It seems to work well, but I was wondering if there was a different recommended approach, and if perhaps an example could be added to the readme.