榆树v0.19补充道expectWhatever
.它Result
在检查错误时表现略有不同,但效果类似.
我expectUnit
为"空"200响应创建了一个帮助器.
expectUnit : Expect () expectUnit = Http.expectStringResponse << always <| Ok () deleteThing : String -> Request () deleteThing path = Http.request { method = "DELETE" , headers = [] , url = "http://localhost/api" , body = Http.jsonBody <| Encode.object [ ( "path", Encode.string path ) ] , expect = expectUnit , timeout = Nothing , withCredentials = False }
但对你来说,你能得到的最好的是.
{ ... , expect = Http.expectStringResponse << always <| Ok playerId ... }
或者你可以创建一个帮助(这实际上是为singleton
或pure
为Expect
)
alwaysExpect : a -> Expect a alwaysExpect = Http.expectStringResponse << always << Ok
哪个可以用
{ ... , expect = alwaysExpect playerId ... }