See ocaml/RFCs#7
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
(* Same example as https://gist.github.com/jordwalke/67819c91df1552009b22 | |
but using OCaml's simple module feature (every file is a module) *) | |
open ReactDOM | |
(* Component Properties *) | |
type props = {count: int} | |
(* Hey, state can be any type! *) | |
type state = string |
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
open ReactDOM | |
module MyComponent = struct | |
(* Component Properties *) | |
type props = {count: int} | |
(* Hey, state can be any type! *) | |
type state = string | |
(* Initializer *) |
There was a [great article][1] about how react implements it's virtual DOM. There are some really interesting ideas in there but they are deeply buried in the implementation of the React framework.
However, it's possible to implement just the virtual DOM and diff algorithm on it's own as a set of independent modules.
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
function run(generator) { | |
// Pass in resume for no-wrap function calls | |
var iterator = generator(resume); | |
var data = null, yielded = false; | |
next(); | |
check(); | |
function next(item) { | |
var cont = iterator.next(item).value; |