榆树效应,滴答函数显然从未被调用

elm effects, the tick function apparently never get called

我试图让我的模型对时钟滴答做出反应,以便制作一些动画,例如榆树架构教程的示例 8(旋转立方体)。

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

由于我的程序无法运行,我尝试制作一个最简单的示例来演示我的问题。

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

当我 运行 单击按钮时,模型会正确更新为 "started",但永远不会触发 Tick 动作。

我可能在这里遗漏了一些东西,但我不知道在哪里。

您缺少任务端口。添加这个,你应该准备就绪:

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