Skip to content

prijs/pri-plugin-dob

Repository files navigation

pri-plugin-dob · npm version

dob is a tool for monitoring object changes, and dob-react can help you manage stores in react.

We provide a pri-plugin for dob!

Usage

npm i pri-plugin-dob

Features

  • Extend webui for store operates.
  • Allow files in path src/stores/**, and automatic binding stores into entry.

Let's try it! For example, create a store named application:

src/stores/application.tsx

import { Action, inject, observable } from 'dob';

@observable
export class ApplicationStore {
  public testValue = 1;
}

export class ApplicationAction {
  @inject(ApplicationStore) public applicationStore: ApplicationStore;

  @Action
  public test() {
    this.applicationStore.testValue++;
  }
}

pri-plugin-dob will automatic create pri/stores for ts defintion, then you can use it like this:

src/pages/index.tsx

import * as React from 'react';
import { stores } from 'pri/stores';

export default class View extends React.PureComponent<typeof stores, any> {
  render() {
    // this.props.ApplicationStore.testValue
    // this.props.ApplicationAction.test()
  }
}

For more skills about using dob in pri, please see dob docs.

About

Dob plugin for pri

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published