Skip to content

Instantly share code, notes, and snippets.

@Raynos

Raynos/docs.mli Secret

Last active January 3, 2016 04:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Raynos/9e159f902a0223bb6315 to your computer and use it in GitHub Desktop.
Save Raynos/9e159f902a0223bb6315 to your computer and use it in GitHub Desktop.
type VirtualDomNode := Object
type Component<T> := {
type: 'component',
render: (data: T) => VirtualDOMNode,
compare?: (left: T, right: T) => Boolean,
data?: T
}
type VirtualDOMTree := {
value: null | VirtualDomNode | Component
children: Array<VirtualDOMTree>
}
type DOMAttributeString := String
type DOMAttributeValue := Any
type DOMPatch := {
path: Array<Number>,
operation: 'attribute' | 'insert' | 'remove'
key?: DOMAttributeString,
value: VirtualDOMTree | DOMAttributeValue | null
}
diff := (left: VirtualDOMTree, right: VirtualDOMTree) => Array<DOMPatch>
batch := (patches: Array<DOMPatch>) => Array<DOMPatch>
applyPatches := (elem: DOMElement, patches: Array<DOMPatch>) => void
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment