@jimengio/rex-legacy
TypeScript icon, indicating that this package has built-in type declarations

0.0.8 • Public • Published

Rex(Legacy)

Rex compatible library for migration old project.

Store abstraction based on immer and OLD Context APIs.

Usage

npm install @jimengio/rex-legacy

Model:

export interface IGlobalStore {
  schemaVersion: string;
  data: number;
  branchData: number;
  homeData: number;
}

export let initialStore: IGlobalStore = {
  schemaVersion: "0.1",
  data: 2,
  branchData: 2,
  homeData: 2,
};
import { createStore } from "rex";

export let globalStore = createStore<IGlobalStore>(initialStore);

View:

import { RexProvider } from "rex";

const renderApp = () => {
  ReactDOM.render(
    <RexProvider value={globalStore}>
      <Container store={globalStore.getState()} />
    </RexProvider>,
    document.querySelector(".app")
  );
};

window.onload = () => {
  renderApp();
  globalStore.subscribe(renderApp);
};

Controller:

export function doIncData() {
  globalStore.update((store) => {
    store.data += 1;
  });
}

Selector:

import { connectRex } from "rex";

@connectRex((store: IGlobalStore, ownProps: IProps) => ({ data: store.data }))
export default class Inside extends React.PureComponent<IProps, IState> {
  render() {
    return <div />;
  }
}

Workflow

https://github.com/jimengio/ts-workflow

License

MIT

Dependents (0)

Package Sidebar

Install

npm i @jimengio/rex-legacy

Weekly Downloads

0

Version

0.0.8

License

ISC

Unpacked Size

13.3 kB

Total Files

8

Last publish

Collaborators

  • imzshh
  • jiyinyiyong
  • rebirth