npm.io
1.0.0-experimental.3 • Published yesterday

@wirestate/mobx

Licence
MIT
Version
1.0.0-experimental.3
Deps
0
Size
22 kB
Vulns
0
Weekly
0

@wirestate/mobx [monorepo] [docs]

npm license

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

npm install @wirestate/mobx mobx

Start

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, and Computed.

Learn More

License

MIT

Keywords