Created
April 10, 2017 14:48
-
-
Save saschatimme/9dc954aacf4c302113de4022c85bd424 to your computer and use it in GitHub Desktop.
Simple trick to avoid decoding / encoding if one use Bucklesript on client and server
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type t = { | |
test: string, | |
value: int | |
}; | |
external consume_client: string => t = "JSON.parse" [@@bs.val]; | |
external prepare_server: t => string = "JSON.stringify" [@@bs.val]; | |
let test = { test: "Hello", value: 42}; | |
Js.log "test:"; | |
Js.log test; | |
let sent = prepare_server test; | |
let consumed = consume_client sent; | |
Js.log "consumed:"; | |
Js.log consumed; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment