Passing context to Subscription::run

After upgrading to latest dev I have problems converting my old subscription::channel code to Subscription::run

I have a config struct that I need to pass. The examples (maybe I missed something?) do not show such an example.

How can I pass arguments to the builder function for Subscription::run?

I created a helper function and tried multiple things now but I am getting errors like

[...]
closures can only be coerced to `fn` types if they do not capture any variables

and I can’t seem to work around it :frowning:

How would it work when the websocket example would have the server address as an argument here: iced/examples/websocket/src/echo.rs at master · iced-rs/iced · GitHub?

Like

pub fn connect(server_address: &str) -> impl Stream<Item = Event> {

You will need to use run_with_id:

1 Like

thank you. that was easy. saw that method and thought “whatever it is I don’t want/need an id”