Created
July 22, 2016 09:03
-
-
Save fxfactorial/8f59fd3e45cc82231263a58bb4e71af1 to your computer and use it in GitHub Desktop.
Ideas that I want to work towards
This file contains hidden or 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
| let javascript_from_ocaml | |
| (* Let me do (object%js val count = 10 end) and count becomes a top | |
| level var count = 10; *) | |
| ?(js_global_values: 'a Js.t option) | |
| (* of course we want to use js_of_ocaml.ppx by default *) | |
| ?(ocaml_pkgs=["js_of_ocaml.ppx"]) | |
| (* self-explanatory *) | |
| ?(minified=true) | |
| (* Only include JavaScript, no linking of the Dom API at all, only | |
| what's limited to the JavaScript language *) | |
| ?(just_javascript=true) | |
| (* These are OCaml .ml files *) | |
| ~(src_files:string list) | |
| () = | |
| "One Long JavaScript String" | |
| type server = unit Server.t -> unit Lwt.t | |
| let routes _ = assert false | |
| let () = | |
| let server : server = | |
| [ | |
| ("/home", | |
| begin fun () -> | |
| let engine = new JavaScriptCore.virtual_machine in | |
| engine#load_javascript ~path:"../static/React.js" (); | |
| engine#load_javascript | |
| ~string:( | |
| javascript_from_ocaml ~src_files:["../front_end/homepage.ml"] () | |
| ) (); | |
| (* Last result from last expression evaluated in this virtual | |
| machine, which for us would be server side React rendered | |
| to HTML *) | |
| engine#last_value | |
| end | |
| ); | |
| ] | |
| |> routes | |
| in | |
| server () | |
| |> Lwt_main.run |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment