build-plugin-ice-store
TypeScript icon, indicating that this package has built-in type declarations

2.0.11 • Public • Published

plugin-store

builtin icestore in icejs

Usage

Directory structure

src
├── models                // global models
│   └── user.ts
└── pages
    ├── About
    │   ├── index.tsx
    │   └── model.ts     // single model
    ├── Dashboard
    │   ├── analysis.tsx
    │   ├── index.tsx
    │   └── models         // multi models
    │       ├── modelA.ts
    │       └── modelB.ts
    └── index.tsx

Define a model

// src/models/user.ts
export default {
  state: {
    user: {}
  },

  actions: {
    getUserInfo: async () => {}
  }
};

With Component

import { store } from 'ice/Home'

const View = () => {
  const [state, actions] =  store.useModel('user')
  // do something...
}

Config

Set global initialstates to src/app.ts:

import { runApp } from 'ice'

const appConfig = {
  // Set global initialstates
  store: {
    initialStates: {}
  }
}

Set page initialstates to src/pages/*/index.tsx:

const HomePage = () => {
  return (
    <>
      <h2>HomePage</h2>
    </>
  )
}

HomePage.pageConfig = {
  // Set page initialstates
  initialstates: {}
}

More

Readme

Keywords

none

Package Sidebar

Install

npm i build-plugin-ice-store

Weekly Downloads

184

Version

2.0.11

License

MIT

Unpacked Size

48.7 kB

Total Files

29

Last publish

Collaborators

  • sobear
  • clarkxia
  • chenbin93
  • solojiang
  • luhengchang228
  • rax-publisher