Closed dylans closed 6 years ago
This could also include synthetic events, push events, etc.
As @matt-gadd pointed out on gitter this can be solved with @dojo/stores
. This can probably be closed in favor of "finish the stores tutorial." Maybe until the tutorial is done you should provide a link to the README. If you are reading through the tutorials you just hit a "coming soon" dead end.
Closing, we have an issue open for the dojo/stores tutorial https://github.com/dojo/dojo.io/issues/224
@schontz commented on Thu Jun 28 2018
I have an app that looks something like:
When you click a button on an
Item
to add it to the cart I want to do the following:Header
widgetIn a reactive app you cannot dig into widgets directly or look at their nodes. What is an elegant way to perform this action? My thought process:
Header
Item.onAddToCart
Search
orCart
pages)App
Header
along with a timestamp, e.g.addedToCart = { timestamp: new Date, payload: data }
.Header
readsaddedToCart
, verifies that it is a new request by comparing the timestamp to the private saved version,_lastAddedToCart
, and if it is a new request it kicks off the animation sequence.My solution requires me to explicitly bubble the event all the way up to the
App
top level through each widget. That is not ideal and brittle. I also happen to be using aContainer
around myItem
s so I added some logic in the container widget which is also not ideal.In my example, if the child widget could set a value on an app-level registry that would make things easier. I don't know if this is the right way(TM), but to get the discussion going...
While my cart example is specific, I think there are some generalities that people coming from dojo 1/non-reactive design will run into:
@dylans commented on Thu Jun 28 2018
I'm going to move this to dojo/meta, as this is an issue that somewhat transcends multiple packages/repos.