builtin icestore
in icejs
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
// src/models/user.ts
export default {
state: {
user: {}
},
actions: {
getUserInfo: async () => {}
}
};
import { store } from 'ice/Home'
const View = () => {
const [state, actions] = store.useModel('user')
// do something...
}
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: {}
}