Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide/Inject-pattern for store #14

Merged
merged 4 commits into from
Jun 19, 2020
Merged

Provide/Inject-pattern for store #14

merged 4 commits into from
Jun 19, 2020

Conversation

gfoidl
Copy link
Contributor

@gfoidl gfoidl commented Jun 19, 2020

So far the state was

  • "shared global"
  • local only -- i.e. for each "use" a new state

With this change the state is encapsulated in a create...Store-function, so a fresh state can be obtained (e.g. for testing). With the provide...Store / use...Store functions a shared state can be managed. A parent component can provide the (shared) state, children can then inject this state.

For the testing the store itself, fresh states can be used, and dependency-injection is possible.

Summarizing, I prefer this provide/inject-pattern over the plain shared state pattern.

@gfoidl gfoidl force-pushed the provide-inject branch 2 times, most recently from caa8d24 to be74ac5 Compare June 19, 2020 18:04
Base automatically changed from composition-api to master June 19, 2020 18:11
@gfoidl gfoidl merged commit 897e758 into master Jun 19, 2020
@gfoidl gfoidl deleted the provide-inject branch June 19, 2020 18:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant