Elm effects, tick function seems to never be triggered

I am trying to get my model to react to the tactics of the clock in order to make some animation, for example, example 8 (rotating cube) of an elm architecture tutorial.

https://github.com/evancz/elm-architecture-tutorial

Since my program does not work, I tried to make a simple example to demonstrate my problem.

module Test where

import Html exposing (..)
import Html.Events exposing (..)
import StartApp as StartApp
import Effects exposing (..)
import Time exposing (..) 

type alias Model =
 {debug : String}

type Action = 
 Start | Tick Time

initialModel = Model "initial"

update : Action -> Model -> (Model, Effects Action)
update action model =
  case action of
    Start  -> ({model | debug = "started"}, Effects.tick Tick)
    Tick _ -> ({model | debug = "hasTicked"}, Effects.none)

view : Signal.Address Action -> Model -> Html
view address model =
  div []
      [ button [onClick address Start] [text "start"]
      , p [] [text (.debug model)]
      ]

app =
    StartApp.start
          { init = (initialModel, Effects.none)
          , view = view
          , update = update
          , inputs = []
          }

main =
    app.html

when I run this, the model updates correctly to “run” when I click the button, but the Tick action never starts.

I probably missed something, but I don’t know where.

+4
source share
1 answer

You are missing a task port. Add this and everything should be installed:

port tasks : Signal (Task.Task Effects.Never ())
port tasks =
  app.tasks
+7
source

Source: https://habr.com/ru/post/1626761/


All Articles