- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我在 a Google Group 中找到了这个问题的可能答案但我想知道它是否正确,如果正确则添加一个后续问题。
答案就在这里
Every time the global update function in your app runs for any reason, the global subscriptions object is reevaluated as well, and effect managers receive the new list of current subscriptions
如果任何时候模型发生变化,subscriptions
都会被调用,这对订阅有什么影响,例如 Time.every second
取自 Time Effect Elm Guide - 这是否意味着模型更改时计时器会重置?如果那是 Time.every minute
- 如果模型在启动后 20 秒发生变化,它会在 60 - 20 = 40 秒
后触发还是会在 后触发1 分钟
?
最佳答案
您可以检查 update
和 subscriptions
何时被调用,方法是为每个调用添加一个 Debug.log
语句。 subscriptions
函数在开始时首先被调用(因为将发送到 update
的消息可能取决于它),并且在每次调用 update
.
计时器间隔似乎不受后续调用
subscriptions
的影响。例如,如果您使用 elm clock example , 将订阅更改为
Time.every (10*Time.second) Tick
并在 View 中添加一个将模型值重置为 0 的按钮,无论您何时单击该按钮,您都会看到滴答仍然以 10 秒的固定间隔发生。
关于elm - 当 Elm Html.Program 调用订阅时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44609208/
基本上我想在悬停时使文本带有删除线。这并不容易使用 el [ mouseOver [Font.strike] ] (text "some text") 就像这样 el [ mouseOver [Bac
基本上我想在悬停时使文本带有删除线。这并不容易使用 el [ mouseOver [Font.strike] ] (text "some text") 就像这样 el [ mouseOver [Bac
以下模式匹配至少有两个元素的列表有什么问题pos1和 pos2 ? type Pos = (Float, Float) type Tail = [Pos] tail_cut : Float -> Ta
我想更新 Elm 类型的记录 type CubeData = {currDirection : Vec3, translation : Vec3, transform : Mat4} 我可以使用以下代
假设有两种数据类型: type alias Player = { name : String , team : Team } type alias Team = { name : St
Python 有它们,我发现它们非常有用: def awesome_fn(x, y): """" Calculates some awesome function of x and y
我正在尝试在 Elm 中设计一个功能,该功能解析来自 Json 的数据,然后将其呈现在一个可排序的表中。 当然,我使用解码器将 Json 数据存储在记录列表中;然后在 View 中,我将记录列表转换为
假设我正在尝试遵循 Elm 架构并将我的工作流程拆分为 User s 和 Invoice s 使用 StartApp . 用户有发票,但他们必须登录才能访问它们。 该模型可能看起来像这样: type
我喜欢 React/Redux 的智能和哑组件概念,其中哑组件不处理自己的状态(Dump 组件对外界一无所知,它所做的只是根据其输入触发事件并显示值) .这是微不足道的,因为所有状态都在一个地方处理(
如何在 elm-repl 中找出 Elm 表达式或子表达式的类型? Haskell 的 :type或 :t相当于 Elm REPL 吗? 最佳答案 Elm REPL 会自动打印您输入的任何类型。例如:
在 Elm 中是否可以通过一个事件处理程序触发多个输入句柄?例如,假设我有以下内容: button [ type' "button", on "click" getAnything go.ha
我正在尝试构建一个通用映射函数,该函数将从联合类型中提取可能的内部类型,对内部值应用转换并将其映射回外部类型。 问题是,我需要一种方法来区分外部类型的特定值是否具有内部类型。 如果下面的代码实际编译了
每隔一段时间,您就会遇到如下编译器错误: It looks like the keyword `port` is being used as a variable. 这很烦人。这些关键词有完整的官方列
我刚刚开始考虑使用 Elm 构建一个简单的 Web 应用程序。我的想法是需要在浏览器中保留一些用户数据。 有没有办法直接用 Elm 处理数据持久化?例如在浏览器 session 甚至本地存储中?或者我
我有这个功能 result = add 1 2 |> \a -> a % 2 == 0) 我收到了这个错误 Elm does not use (%) as the remainder operat
编写一个函数将一个列表分成两个列表。第一部分的长度由调用者指定。 我是 Elm 的新手,所以我不确定我的推理是否正确。我认为我需要转换数组中的输入列表,以便我能够按提供的输入数字对其进行切片。我也在语
我正在尝试创建一个简单的Elm项目,仅插入“hello world!”串成div。 这是我的代码: index.html: ELM Course
我正在编写elm程序,该程序应将其输出格式化为HTML列表。我要的功能 inputs = ["first", "second", "third"] 并输出本质上是某种Elm Element,
在 Elm 中,我无法弄清楚什么时候 type 是合适的关键字,什么时候 type 别名 才是合适的。文档似乎没有对此进行解释,我也无法在发行说明中找到这一解释。这是否记录在某处? 最佳答案 我的想法
我刚刚开始学习 Elm,并且在理解为什么将自定义类型传递到期望的方法时遇到类型不匹配的问题......好吧,我称之为部分类型注释. 这是我正在使用的代码: import Graphics.Elemen
我是一名优秀的程序员,十分优秀!