UNPKG

vue-mobx-finegrained

Version:

Vue 3 composable for a complete MobX state management integration.

33 lines (24 loc) 723 B
import { inject, injectable } from 'inversify' import { computed, makeObservable } from 'mobx' import { MessagesRepository } from './Core/Messages/MessagesRepository' import { Router } from './Routing/Router' @injectable() export class AppPresenter { @inject(Router) router: Router @inject(MessagesRepository) messagesRepository: MessagesRepository get currentRoute () { return this.router.currentRoute } constructor () { makeObservable(this, { currentRoute: computed, }) } load (onRouteChange = () => {}) { const onRouteChangeWrapper = () => { this.messagesRepository.appMessages = [] onRouteChange() } this.router.registerRoutes(onRouteChangeWrapper) } }