This repository has been archived by the owner on Nov 17, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
feat: store initialStates #435
Merged
Merged
Changes from 12 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
bc486db
feat: store initialStates
luhc228 25994a1
chore: update README
luhc228 c5cfc98
chore: add file comment
luhc228 e147f20
chore: rename type
luhc228 01e6798
Merge branch 'release-next' into feat/store-initialStates
luhc228 8c60c4b
fix: peer dependencies
luhc228 2c7ee75
fix: defineStoreConfig not found
luhc228 90f2858
Merge branch 'release-next' into feat/store-initialStates
luhc228 d089be3
feat: support get the appData
luhc228 b761f58
fix: test case
luhc228 7bd7a01
fix: conflict
luhc228 94f1480
fix: lock
luhc228 b539263
fix: conflict
luhc228 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,23 @@ | ||
import { defineAppConfig } from 'ice'; | ||
import { defineStoreConfig } from '@ice/plugin-store/esm/types'; | ||
|
||
export const store = defineStoreConfig(async (appData) => { | ||
// fetch Data | ||
return { | ||
initialStates: { | ||
...appData, | ||
}, | ||
}; | ||
}); | ||
|
||
export const getAppData: GetAppData = () => { | ||
return new Promise((resolve) => { | ||
resolve({ | ||
user: { | ||
name: 'icejs', | ||
}, | ||
}); | ||
}); | ||
}; | ||
|
||
export default defineAppConfig({}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,6 @@ import { createModel } from 'ice'; | |
|
||
export default createModel({ | ||
state: { | ||
name: 'ICE 3', | ||
name: '', | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# @ice/plugin-store | ||
|
||
A plugin of state management base on Redux and React Redux used in framework `ICE`. | ||
|
||
## Usage | ||
|
||
```ts | ||
import { defineConfig } from '@ice/app'; | ||
import store from '@ice/plugin-store'; | ||
export default defineConfig({ | ||
plugins: [ | ||
store(), | ||
], | ||
}); | ||
``` | ||
|
||
## Options | ||
|
||
- disableResetPageState: 默认值是 `false`。开启后,切换页面再次进入原页面后不会重新初始化页面状态 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
export interface StoreConfig { | ||
initialStates: Record<string, any>; | ||
} | ||
|
||
type Store = ((data?: any) => Promise<StoreConfig>) | StoreConfig; | ||
|
||
function defineStoreConfig(fn: Store) { | ||
return fn; | ||
} | ||
|
||
export { | ||
defineStoreConfig, | ||
}; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
为啥需要这个
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
所以项目依赖中你会推荐把 tslib 也默认加进去吗
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
看 next 也会加 tslib
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
好多地方都会用到, ts 优先的话我也建议脚手架默认加 tslib 在 devDep
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
或者也可以默认先不依赖 tslib,把可能遇到的错误以及解决方式(安装一下 tslib)放在 faq 中
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里不用增加复杂度了, 直接脚手架里依赖上吧 (开箱即用)