Learn about our RFC process, Open RFC meetings & more.Join in the discussion! »

@jimengio/rex-legacy

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

Keywords

none

Install

npm i @jimengio/rex-legacy

DownloadsWeekly Downloads

7

Version

0.0.8

License

ISC

Unpacked Size

13.3 kB

Total Files

8

Last publish

Collaborators

  • avatar
  • avatar
  • avatar
  • avatar
  • avatar