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

Content: add Component Composition > Context #42

Open
matschik opened this issue May 5, 2022 · 5 comments
Open

Content: add Component Composition > Context #42

matschik opened this issue May 5, 2022 · 5 comments
Labels
content specific to `content` directory enhancement New feature or request

Comments

@matschik
Copy link
Owner

matschik commented May 5, 2022

React: https://fr.reactjs.org/docs/hooks-reference.html#usecontext
Svelte: https://svelte.dev/tutorial/context-api
Vue 3:
SolidJS: https://www.solidjs.com/tutorial/stores_context

@matschik matschik added enhancement New feature or request content specific to `content` directory labels May 5, 2022
@stondbringa
Copy link

The equivalent for Vue 3 is Provide/Inject: https://vuejs.org/guide/components/provide-inject.html

@matschik
Copy link
Owner Author

matschik commented Jan 8, 2023

React & Svelte examples are now available

@matschik matschik pinned this issue Jan 8, 2023
@mroeling
Copy link
Contributor

mroeling commented Jan 8, 2023

Hi @matschik ,

Was trying to understand the goal of these code snippets. Could you give a bit more context (no pun intended) of what is the goal of this example?
From a Aurelia point of view, since it is class based, things can be done by using Dependency Injection. Another option is using the Event system. Using aurelia-store (i.e. RxJs state management) it is also possible.

@matschik
Copy link
Owner Author

matschik commented Jan 8, 2023

Explained by React docs: https://beta.reactjs.org/learn/passing-data-deeply-with-context
Explained by Svelte docs: https://svelte.dev/tutorial/context-api
Explained by Vue docs: https://vuejs.org/guide/components/provide-inject.html

Context VS Store (from Svelte link)

Contexts and Stores seem similar. They differ in that stores are available to any part of an app, while a context is only available to a component and its descendants. This can be helpful if you want to use several instances of a component without the state of one interfering with the state of the others.
In fact, you might use the two together.

Additionnally,store is planned for Component Party.

@harshilparmar
Copy link

For Angular , Is it to good to mention service in this place? Yeah there is no such concept of context but using service we can eventually achieve that behavior.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
content specific to `content` directory enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants