@wirestate/mobx [monorepo] [docs]
Framework-agnostic MobX exports for Wirestate services.
Use this package to create observable services once and share them across React and Lit applications. Pair it with @wirestate/react-mobx to render React components or @wirestate/lit-mobx to render Lit elements.
Install
bash
npm install @wirestate/core @wirestate/mobxStart
ts
import { Injectable } from "@wirestate/core";
import { Action, Observable, makeObservable } from "@wirestate/mobx";
@Injectable()
class CounterService {
@Observable()
public count = 0;
public constructor() {
makeObservable(this);
}
@Action()
public increment(): void {
this.count++;
}
}The same CounterService can now be consumed from a React component (via @wirestate/react-mobx) or a Lit element (via @wirestate/lit-mobx) without changes.
What Is Included
- Re-exports from
mobx. - Decorator aliases:
Observable,ShallowObservable,RefObservable,DeepObservable,Action,BoundAction, andComputed.
Learn More
License
MIT