Skip to content

Latest commit

 

History

History
56 lines (39 loc) · 1.44 KB

readme.md

File metadata and controls

56 lines (39 loc) · 1.44 KB

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.