Skip to content

How to think about writing de/serializers in Fable? #2909

Discussion options

You must be logged in to vote

There's some reflection support in Fable, but objects don't carry extra type info with them so it must be resolved at compile time (this is by design so Fable apps are compatible with JS tree shaking). The usual pattern is to offer two functions: one generic and inlined that gets the type info argument and just calls another function (not inlined) that receives the Type argument. You can see this pattern in Thoth.Json for example: https://github.com/thoth-org/Thoth.Json/blob/358ba12ac50ebac175bbfea98f9df20c0ddd1189/src/Decode.fs#L1233-L1238

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by NickDarvey
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants