refstore
State management for Inferno. Tiny bundle, MobX-like API. Built-in optional router.
Usage
Load data in your service:
;; async { const _ = encodeURIComponent; /** @type {{ [id: string]?: Post }?} */ thisposts = ...thisposts || {} id: await ; // Note: Only tracks reference. Don't mutate; replace. } ;
Make your view an observer, and inject the service:
;; /** * @typedef IProps * @property {{ params: { id: string } }} match * @property * @property * * @extends Component<IProps> */ { thispropspostService; } { const formatTime = thispropslocaleService; const params = thispropsmatch; const posts = thispropspostService; const post = posts || {}paramsid || ; return <blockquote id=paramsid> <small> postname </small> posttext || "..." </blockquote> ; } const PostScreen = ;
Configure the routes:
; static routes = component: HomeScreen exact: true path: "/" component: PostScreen "/posts/:id" ; { return <Switch> Approutes </Switch> ; }
See practical examples at https://github.com/makepost/serverside, import refstore
everywhere it has MobX or React Router.
TypeScript definitions list components and other exports, which should be familiar if you have used the libraries mentioned above: BrowserRouter, History, Link, Location, Provider, Route, StaticRouter, Switch, autorun, decorate, inject, isObservableProp, matchPath, observable, observer, useStaticRendering, withRouter.
License
MIT