-
-
Notifications
You must be signed in to change notification settings - Fork 37
Description
Description
First up, i may just completely miss the point as i have not worked too closely with react or elm.
Currently, if there are events(via UserEvents) that would need to be handled by no particular component and directly by Update, the message would have to pass through a bunch of forwarding(likely via a global listener) that could be skipped if a variant on Event would exit for Messages directly.
For example imagine a Event from a custom port that got new data, whereupon a new component(or multiple) should be shown, or Model state needs to be adjusted.
Or more concretely, image a server-client application, where the client gets a notification that the server exited, which would (to my knowledge) not need to be handled by a particular component, but would need to be directly handled on Update, by opening a popup.
Changes
Add new Event variant that forwards Messages, bypassing forwarding to the components.
Implementation
Due to a new variant that requires a generic, it would need adjustment everywhere Event is used.
Currently there are 2 workarounds i can image:
- the one i outlined earlier: add a
UserEventwith variant likeForward(Msg)and a global listener which just consumesEvents and produces theMsg - disregard the tuirealm stack and just call
model.updatefrom the outside manually with each gotten message (this is how termusic currently works / the actual function)
PS: i have now implemented the UserEvents-forwarding way for termusic in a separate branch as a try, which works but seems somewhat inefficient to me.
Also changing from NoUserEvent to UserEvent or event trying to mix them is quite a annoying experience, though i dont know if anything can be done about that.