-
Notifications
You must be signed in to change notification settings - Fork 32
IE 11 serialization problem #130
Comments
Hello @halcwb, Do you have a warning/error in the console? Are you using auto or manual coders? Could you please provide reproduction code?
|
Hello @MangelMaxime This is the code I use to send a request using Thoth encoding: let post req =
let decode = Decode.Auto.unsafeFromString<Response Option>
promise { let! res = postRecord "/api/request" req []
let! resp= res.text()
return resp |> decode }
let requestToResponseCommand respMsg reqMsg =
reqMsg
|> post
|> (fun task ->
Cmd.ofPromise (fun () -> task) () (Ok >> respMsg)
(Result.Error >> respMsg))
Well, actually it is the postRecord method which performs the serialization, but this in turn uses Thoth.Json as well, I think. To be sure, the |
As a related issue, I discovered that the powerpack lib is no longer in use. The postRecord depends both on Fable.Fetch and Fable.Promise. So, this function is deprecated as well. It is rather trivial to create the function yourself. But when people upgrade to the seperate Fable.Fetch and Fable.Promise, this could be a bit of a surprise. |
Having a reproduction types would helps, so is your type of the form: type Data =
{ Value : int }
type NestedUnion =
| Data of Data
type Repro =
| CaseA of NestedUnion
Yes, we decided to split the A solution could be to create a It could be accessible from |
The exact type in question which causes the problem is: module Types =
module Configuration =
type Configuration = Setting list
and Setting =
{ Department : string
MinAge : int
MaxAge : int
MinWeight : float
MaxWeight : float }
module Patient =
module Age =
type Age =
{ Years : int
Months : int
Weeks : int
Days : int }
type Age = Age.Age
/// Patient model for calculations
type Patient =
{ Age : Age
Weight : Weight
Height : Height }
/// Weight in kg
and Weight =
{ Estimated : double
Measured : double }
/// Length in cm
and Height =
{ Estimated : double
Measured : double }
module Treatment =
type MedicationDefs = (string * string * float * float * float * float * string * string) list
module Request =
module Configuration =
type Msg = Get
module Patient =
type Patient = Patient.Patient
type Msg =
| Init
| Calculate of Patient
module AcuteList =
type Msg = Get
type Msg =
| PatientMsg of Patient.Msg
| ConfigMsg of Configuration.Msg
| AcuteListMsg of AcuteList.Msg So, in this case a Patient |> Calculate |> PatientMsg which is a Request.Msg. |
Thank you for the reproduction code :) It will help work on the issue. |
I moved this issue to another repository, and further work will take place there. |
When trying to serialize an object like:
["PatientMsg",["Calculate",{"Age":{"Years":6,"Months":0,"Weeks":0,"Days":0},"Weight":{"Estimated":15,"Measured":15},"Height":{"Estimated":98,"Measured":0}}]]
in IE, what is created is:
["PatientMsg",["Calculate",[]]]
So the object in the discriminated union is not serialized in IE 11.
The text was updated successfully, but these errors were encountered: