In a sliding puzzle game, I would like to set the initial tile size based on the initial window size (to increase the screen real estate).

In other words, I would like to set initialModel based on the initial value of Window.dimensions .
I could not find how to do this, and ended up using ports to get the initial size of the window:
index.html
Elm.fullscreen(Elm.App, { windowSize: [ document.documentElement.clientWidth, document.documentElement.clientHeight ] });
App.elm
port windowSize : (Int, Int) initialModel = -- some function of windowSize model = Signal.foldp update initialModel input type Action = WindowResize (Int, Int) | ... windowResize = Signal.map WindowResize Window.dimensions update action model = case action of WindowResize dimensions -> { model | some change based on dimensions } ...
Is there a way to achieve the same result without using ports?
source share