-
-
Save Raynos/9e159f902a0223bb6315 to your computer and use it in GitHub Desktop.
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 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