This is a small detail, but it’s been annoying me incessantly for a long time:
There are times when I need the current time in the initial model, and times when I need the window size in the initial model.
I know, I can pass them in through flags or I can grab make them the initial Cmd msg. These are the two approaches I follow. But…
- I make a lot of small applications that are full screen and don’t use ports or flags at all, and thus, just setting up the embedding of the elm app in an empty html document is a minor annoyance (also requires an extra request to the server, versus compiling to an index.html).
2.) getting it with the first Cmd msg means my first frame doesn’t have the information, leading to a flash or requiring me to make a loading animation (and even then, getViewport and Time.now work so fast that there’s no time to see the animation.
Like I said, this is a minor annoyance, but nonetheless, it is annoying me.
I wonder if we could provide an alternative init field somehow, that instead of producing a flags -> (model, Cmd msg)
(or whatever variant), produced a `Cmd (Task Never x) -> (model, Cmd msg)’?
The reason for restricting it to Task Never x, instead of any task, is that tasks that might fail or have latency probably shouldn’t be used here, but it does seem silly that there’s not an easy way to load window size and current time, both of which the runtime can be guaranteed to grab extremely fast before our first rendering of view.
Am I missing something?
This is the sort of thing like a door that pulls when it clear should push that really annoys me.