Description
@MartinKavik @David-OConnor I'm starting to get half a mind to move the Init
from build
to run
or something similar to isolate all the side effects inside of run
instead of distributing the stateful effects across finish
and run
.
I think that this is better since we do this weird dance around initial_orders
right now where we don't quite have the correct state to do what we have half the state we want inside Builder
and half the state inside the App
.
So we would have
App::build(update, view).finish().run_with_init(|_, _| {
// Do things with url + orders.
// `Init::default` is a wrapper for `Init::new(Model::default())`.
Init::default()
})
or
App::build(update, view).finish().run() // Calls `Init::default` by default.
It's a bit of a departure from what we currently have, but I think that it makes the implementation a little less weird and the usage clearer about when exactly the InitFn
happens (since it seems to run half in finish
and half in run
right now).
Personally, I also think that mount
should also be inside Init
since we might want to mount it to a different place depending on the initial route, but we seem to keep that around forever, so I changed my mind. Point is, there are parts of AppCfg
that are not immutable, and I would like to change that.
The downsides, I think, are also fairly obvious in that it's a breaking change, and so on. Also, the model is now provided in the run
method instead of the build
method, which is also... unique, so to speak.
I haven't seen if the types work out yet, but it seems reasonable to me.
Originally posted by @AlterionX in #235 (comment)