Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the equivalent of react context in glimmerjs?

I've been using react for the past three years and just watched a few talks about ember and glimmer and got interested in glimmer. So excuse my ignorance if the question doesn't make sense.

What will be an equivalent of a global state / context in a glimmer app? What I'm looking for is a @tracked data which can be accessed deep in the component tree without passing it as argument at each level. Think redux without all those ceremonial action/action-creator/reducer.

A single global atom with bunch of functions to immutably modify it and re-actively see the change on the component tree.

like image 895
Sam R. Avatar asked Oct 16 '22 11:10

Sam R.


1 Answers

Perhaps you are wanting to use services?

https://guides.emberjs.com/release/applications/services/

Services are app level state, and you can use 'injections' to get access to them deep in your component tree, similar to UseContext.

Also, you may be interested in this: https://www.notion.so/Ember-For-React-Developers-WIP-556a5d343cfb4f8dab1f4d631c05c95b (at http://emberatlas.com, in case the page gets renamed)

There is a section on global state / services / contexts

Note: Glimmer components are not the default component until ember 3.14

like image 155
NullVoxPopuli Avatar answered Nov 15 '22 05:11

NullVoxPopuli