component-party.dev icon indicating copy to clipboard operation
component-party.dev copied to clipboard

Content: add `Component Composition > Context`

Open matschik opened this issue 2 years ago • 5 comments

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 avatar May 05 '22 13:05 matschik

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

stondbringa avatar Aug 09 '22 13:08 stondbringa

React & Svelte examples are now available

matschik avatar Jan 08 '23 17:01 matschik

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.

mroeling avatar Jan 08 '23 21:01 mroeling

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.

matschik avatar Jan 08 '23 21:01 matschik

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.

harshilparmar avatar Mar 07 '23 06:03 harshilparmar