diff options
author | Joris | 2023-02-19 13:16:53 +0100 |
---|---|---|
committer | Joris | 2023-02-19 13:25:29 +0100 |
commit | 8b84a732436fc6c84ce4b912b548648eb91c9312 (patch) | |
tree | 9b86b1a4c14f6e8bd83013644cd29f954e590afe /src/rx.ts | |
parent | e1aaa513a444a32c56a9591dd92beb24e66bcf42 (diff) |
Rename withVar to withState
Diffstat (limited to 'src/rx.ts')
-rw-r--r-- | src/rx.ts | 34 |
1 files changed, 18 insertions, 16 deletions
@@ -1,14 +1,16 @@ +// Rx 1.0.1 + // Html export type Html - = false - | undefined - | string - | number - | Tag - | WithVar<any> + = false + | undefined + | string + | number + | Tag + | WithState<any> | Array<Html> - | Rx<Html> + | Rx<Html> interface Tag { type: 'Tag' @@ -19,8 +21,8 @@ interface Tag { onunmount?: (element: Element) => void } -interface WithVar<A> { - type: 'WithVar' +interface WithState<A> { + type: 'WithState' init: A getChildren: (v: Var<A>) => Html } @@ -40,8 +42,8 @@ type AttributeValue function isHtml(x: any): x is Html { return (typeof x === 'string' || typeof x === 'number' - || isTag(x) - || isWithVar(x) + || isTag(x) + || isWithState(x) || isRx(x) || Array.isArray(x)) } @@ -88,9 +90,9 @@ export function h( } } -export function withVar<A>(init: A, getChildren: (v: Var<A>) => Html): WithVar<A> { +export function withState<A>(init: A, getChildren: (v: Var<A>) => Html): WithState<A> { return { - type: 'WithVar', + type: 'WithState', init, getChildren } @@ -322,7 +324,7 @@ function appendChild(state: State, element: Element, child: Html, lastAdded?: No remove: () => element.removeChild(childElement), lastAdded: childElement, } - } else if (isWithVar(child)) { + } else if (isWithState(child)) { const { init, getChildren } = child const v = state.register(init) const children = getChildren(v) @@ -374,8 +376,8 @@ function isTag<A>(x: any): x is Tag { return x !== undefined && x.type === "Tag" } -function isWithVar<A>(x: any): x is WithVar<A> { - return x !== undefined && x.type === "WithVar" +function isWithState<A>(x: any): x is WithState<A> { + return x !== undefined && x.type === "WithState" } function appendNode(base: Element, node: Node, lastAdded?: Node) { |