Skip to content

[Feature Request] - Event type to directly send a Msg #110

@hasezoey

Description

@hasezoey

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:

  1. the one i outlined earlier: add a UserEvent with variant like Forward(Msg) and a global listener which just consumes Events and produces the Msg
  2. disregard the tuirealm stack and just call model.update from 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.

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions