title | layout |
---|---|
Elm 0.16 |
page |
Warning: This page concerns Elm version 0.16. The information here is no longer correct for the current version of Elm.
For general questions about the current version see the main FAQ page.
You need to install the Html module:
elm package install evancz/elm-html
Several modules are available by default in the base Elm tools but other common modules like Html have to be installed in the working directory before they can be used in elm-make, elm-repl, and elm-reactor.
Effects.task (Task.succeed SomeAction)
You need to set app.port
.
port tasks : Signal (Task.Task Never ())
port tasks =
app.tasks
It was removed in Elm version 0.16. You can still get it (or the equivalent andMap
) from
Signal.Extra
instead.
For example, given this:
modelInit = { window = (-1,-1) }
main = Signal.map Element.show model
model = Signal.foldp (\d s -> {s | window = d}) modelInit Window.dimensions
the displayed value will remain at "{ window = (-1,-1) }" until the window is resized, at which time the display tracks all changes.
This arises because Signal.foldp
does not use the initial value of its input signal (Window.dimensions
in this case).
One solution is to use the foldp'
function from the Apanatshka/elm-signal-extra package, as follows:
model = Signal.Extra.foldp' (\d s -> {s | window = d}) (\d -> { window = d }) Window.dimensions
Whereas foldp
takes an initial value parameter, foldp'
takes instead a function from the initial value of the input signal to the initial value returned by foldp'
.
Since StartApp uses foldp
this problem with initial values can arise when it is used. Also, the problem is not specific to Window.dimensions; it can arise for any input signal whose initial value is of interest.
That can happen if you write custom Javascript code to call Elm.embed()
or Elm.fullscreen()
and the application name used there (the first parameter) does not match the main module name.
For example, if Foo.elm contains the main
function for your app then your Javascript code should call it like this:
app = Elm.embed(Elm.Foo, ...)
If you use a name other than Elm.Foo
there you will likely get that "Cannot read property" error.