@nent/core
Version:
31 lines (30 loc) • 784 B
JavaScript
/*!
* NENT 2022
*/
/* istanbul ignore file */
import { createStore } from '@stencil/store';
export class RoutingStateModel {
constructor() {
this.hasExactRoute = false;
this.debug = false;
}
}
const store = createStore({
router: null,
location: null,
hasExactRoute: false,
debug: false,
});
const { state, onChange, reset, dispose } = store;
let subscribed = false;
onChange('router', router => {
if (router && subscribed == false) {
router.eventBus.on('*', () => {
state.hasExactRoute = false;
state.location = router.location;
state.hasExactRoute = router.hasExactRoute();
});
subscribed = true;
}
});
export { state as routingState, onChange as onRoutingChange, reset as routingStateReset, dispose as routingStateDispose, };