作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有这段代码,我正在使用 Fable Elmish 和 Fable remoting 连接到 Suave 服务器。我知道服务器由于 postman 而工作,并且此代码的变体确实调用了服务器
let AuthUser model : Cmd<LogInMsg> =
let callServer = async {
let! result = server.RequestLogIn model.Credentials
return result
}
let result = callServer |> Async.RunSynchronously
match result with
| LogInFailed x -> Cmd.ofMsg (LogInMsg.LogInRejected x)
| UserLoggedIn x -> Cmd.ofMsg (LogInMsg.LogInSuccess x)
callServer
let 结果中的行以
Object(...) is not a function
失败,但我不明白为什么。任何帮助,将不胜感激。
最佳答案
根据 Fable 文档 Async.RunSynchronously
不支持,但我不确定这是否会导致您的问题。无论如何,您应该构建您的代码,以便您不需要阻止异步计算。如果是 Elmish,您可以使用 Cmd.ofAsync
从异步中创建一个命令,该命令在完成时调度异步返回的消息。
let AuthUser model : Cmd<LogInMsg> =
let ofSuccess result =
match result with
| LogInFailed x -> LogInMsg.LogInRejected x
| UserLoggedIn x -> LogInMsg.LogInSuccess x
let ofError exn = (* Message representing failed HTTP request *)
Cmd.ofAsync server.RequestLogIn model.Credentials ofSuccess ofError
关于f# - 寓言 Elmish 中的异步命令,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49891110/
我有这段代码,我正在使用 Fable Elmish 和 Fable remoting 连接到 Suave 服务器。我知道服务器由于 postman 而工作,并且此代码的变体确实调用了服务器 le
我很难在 Fable 中引用无参数函数。 用这个例子: let f1 () = 1 let someRefTof1 = f1 我希望生成的 js 看起来像这样: function f1() {
我是一名优秀的程序员,十分优秀!