Elm在更新功能中将邮件发送到邮箱
我在Elm StartApp MUV框架的更新函数中有以下操作处理程序Elm在更新功能中将邮件发送到邮箱,elm,Elm,我在Elm StartApp MUV框架的更新函数中有以下操作处理程序 signupAlertMailbox : Signal.Mailbox String signupAlertMailbox = Signal.mailbox "" update : Action -> Model -> (Model, Effects Action) update action model = case action of Submit -> let isInp
signupAlertMailbox : Signal.Mailbox String
signupAlertMailbox =
Signal.mailbox ""
update : Action -> Model -> (Model, Effects Action)
update action model =
case action of
Submit ->
let isInputValid = Dict.foldl (\fieldName fieldState validity -> if validity
then (fieldState == IsOkay)
else validity)
True model.inputState
rnd = log "Input valid" isInputValid
-- in (model, Effects.none)
in if isInputValid
then (model, Signal.send signupAlertMailbox.address "Oh snap! Change a few things up and try submitting again."
|> Effects.task
|> Effects.map (always Submit))
else (model, Signal.send signupAlertMailbox.address "Well done! All input correct!"
|> Effects.task
|> Effects.map (always Submit))
提交操作后,我可以在浏览器控制台中看到日志消息,但没有消息发送到signupAlertMailbox。请帮我解决这个问题
--编辑
STARTAP布线代码如以下注释所示:
import StartApp exposing (start)
import Time exposing (every, second)
import Pages.Signup.Model
import Pages.Signup.Update exposing (signupAlertMailbox)
import Pages.Signup.View
app =
start
{ init = Pages.Signup.Model.init
, view = Pages.Signup.View.view
, update = Pages.Signup.Update.update
, inputs = []
}
原因是我没有把app.tasks交给一个端口来执行,正如上面Chad Gilbert@Chad Gilbert在评论中提到的那样。谢谢 我添加了以下部分,并开始从更新功能获取sigupAlertMailbox中的这些邮件
port tasks : Signal (Task.Task Never ())
port tasks =
app.tasks
你能把你的代码上传到StartApp吗?通常,当
start
的返回值未将app.tasks
分配给端口时,就会出现这种类型的问题。我已经添加了代码连接StartApp。请帮我做这件事。谢谢。我把app.tasks交给了你提到的端口,效果很好。谢谢!:)哦,好吧,我对Elm还不熟悉,而且仍然能理解信号、任务和效果。不要重复了,别担心!该标志只是标准的堆叠溢出策展。它为将来可能有类似问题的网站访问者留下了书面记录。