[WIP] Type safe store binding helper #16
Open
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.
This PR add a new helper function
bindStore
(the name may be changed) to create a Vue component that has mapped state/getters/mutations/actions.The main difference with the existing decorators, the mapped properties/methods can be inferred with its types. It uses the same strategy of vuejs/vuex#1121 which is on going typings improvement of Vuex.
At first, the users should declare module asset types:
Then, create a store-bound component by using
bindStore
. Make sure you annotate the module types to the function. It can chains some static methods to map module assets on the component:Finally, extend the component so that you use typed store assets on the extended component.
This should be merged after vuejs/vuex#1121 is released.
fix #2