Quark
#
Modules #
quark/actionquark/appquark/bubblesquark/bufferquark/checkboxquark/cssquark/ctrquark/defsquark/dialogquark/eventquark/fontquark/fsquark/hashquark/httpquark/indexquark/jsonbquark/keyboardquark/lmdbquark/mediaquark/navquark/netquark/osquark/pathquark/pkgquark/screenquark/statequark/stepperquark/storagequark/testquark/typesquark/uriquark/utilquark/viewquark/windowquark/wsquark/_bufferquark/_commonquark/_decoratorsquark/_eventquark/_extquark/_md5quark/_sha1quark/_sha256quark/_utilquark/_watching
Quark v1.4.0 Documentation
Contents
-
quark/ctr
- Args
- RenderOpts
- Interface: DOMConstructor
- assertDom(subclass,baseclass,...args)
- link(target,name)
- linkAcc(target,name)
- Class: VirtualDOM
- Class: DOMCollection
-
Class: ViewController
- ViewController
- viewcontroller.window
- viewcontroller.owner
- viewcontroller.children
- viewcontroller.props
- viewcontroller.state
- viewcontroller.refs
- viewcontroller.ref
- viewcontroller.dom
- viewcontroller.isLoaded
- viewcontroller.isMounted
- viewcontroller.isDestroyd
- viewcontroller.metaView
- viewcontroller.constructor(props,arg)
- viewcontroller.setState(newState)
- viewcontroller.update()
- viewcontroller.triggerLoad()
- viewcontroller.triggerMounted()
- viewcontroller.triggerUpdate(old,vdom)
- viewcontroller.triggerUnload()
- viewcontroller.render()
- viewcontroller.appendTo(parent)
- viewcontroller.afterTo(prev)
- viewcontroller.destroy()
- createElement(Type,props,...children)
- VDom
- RenderData
- RenderNode
- RenderResult
quark/ctr #
Args #
Arguments used to construct a VirtualDOM instance.
type Args =
{
window: Window; // bound window instance
owner: ViewController; // parent controller
children: (VirtualDOM | null)[]; // child virtual nodes
}
RenderOpts #
Options for rendering a VirtualDOM.
type RenderOpts =
{
parent?: View | null; // optional parent view to append to
replace?: object; // replace:?{vdom?: VirtualDOM | null,dom?: DOM | null}
}
Interface: DOMConstructor #
DOMConstructor #
Constructor type for DOM elements.
Type parameters: T
assertDom(subclass,baseclass,...args) #
Assert that a VirtualDOM belongs to a specific DOM subclass.
assertDom(subclass: VirtualDOM<T>, baseclass: DOMConstructor<T>, args: any[])
Type parameters: T
link(target,name) #
Decorator to link an external prop to a class field.
- Copies the value from
propsinto the class property when initializing/updating. - One-way binding only: changes to props propagate into the class field, but class field changes do not propagate back to props.
- Useful for simplifying access: instead of
this.props.foo, you can usethis.foo.link(target: ViewController, name: string)
linkAcc(target,name) #
Decorator to link an external prop with getter/setter accessors.
- Also a one-way binding from props to the class field.
- Provides an accessor so that if the field is reassigned inside the class,
it triggers
update()automatically (but does not affect props).linkAcc(target: ViewController, name: string)
Class: VirtualDOM #
VirtualDOM #
Represents a Virtual DOM node. Can be a View, ViewController, or other custom DOM elements.
Type parameters: T
virtualdom.getPropHash(prop) #
Get hash for a specific property.
getPropHash(prop: string): number | undefined
Parameters:
prop— Property name
Returns: hash value
virtualdom.diffProps(dom,vdomOld) #
Diff props against old VirtualDOM and update the real DOM as needed.
diffProps(dom: T, vdomOld: VirtualDOM)
Parameters:
dom— Real DOM instancevdomOld— Previous VirtualDOM
virtualdom.diff(owner,vdomOld,domOld) #
Diff this VirtualDOM with a previous one and update the real DOM.
diff(owner: ViewController, vdomOld: VirtualDOM, domOld: DOM): T
Parameters:
owner— Owning ViewControllervdomOld— Previous VirtualDOMdomOld— Previous real DOM
Returns: Updated DOM
Type parameters: P, S
virtualdom.newDom(owner) #
Creates a new real DOM instance from this VirtualDOM.
newDom(owner: ViewController): T
Parameters:
owner— Owning ViewController
Returns: New DOM instance
Type parameters: P, S
virtualdom.render(owner,opts?) #
Renders the VirtualDOM, optionally diffing against previous DOM.
render(owner: ViewController, opts?: RenderOpts): T
Parameters:
owner— Owning ViewControlleropts?— Optional render options
Returns: The rendered DOM
Type parameters: P, S
Class: DOMCollection #
DOMCollection #
Collection of real DOM elements produced from a virtual DOM collection.
Implements: DOM
domcollection.collection #
Child DOM elements
readonly collection: DOM[]
domcollection.keys #
Keyed mapping
readonly keys: Map<string | number,[DOM,VDom]>
domcollection.ref #
Ref name in parent
readonly ref: string
domcollection.owner #
Owning ViewController
readonly owner: ViewController
Class: ViewController #
ViewController #
UI view controller component. Base class for all ViewControllers. Handles state, props, children, refs, lifecycle hooks, and rendering.
Implements: DOM
Type parameters: P, S
viewcontroller.window #
Associated Window Window object ref
readonly window: Window
viewcontroller.owner #
Parent controller which the current controller belongs
readonly owner: ViewController
viewcontroller.children #
External children vdom
readonly children: (VirtualDOM | null)[]
viewcontroller.props #
the ViewController external incoming attributes
readonly props: Readonly<P>
viewcontroller.state #
View Controller States
readonly state: Readonly<S>
viewcontroller.refs #
Subordinate objects referenced by the ref name
readonly refs: Readonly<Dict<ViewController | View>>
viewcontroller.ref #
The Ref-Name in the owner controller
readonly ref: string
viewcontroller.dom #
The rendered DOM object under the current ViewController
readonly dom: DOM
viewcontroller.isLoaded #
After triggering Load, it will be set to true
readonly isLoaded: boolean
viewcontroller.isMounted #
It will be set to true before triggering Mounted
readonly isMounted: boolean
viewcontroller.isDestroyd #
It will be set to true before triggering Destroy
readonly isDestroyd: boolean
viewcontroller.metaView #
readonly metaView: View
viewcontroller.constructor(props,arg) #
Constructs a ViewController.
constructor(props: object, arg: Args)
Parameters:
props— External propsarg— Additional args (window, owner, children)
viewcontroller.setState(newState) #
Update the current ViewController state and re-render if the state does change
setState(newState: any): Promise<void>
Parameters:
newState— Partial state to update
Returns: resolves after re-render completes
viewcontroller.update() #
Force re-rendering of the ViewController
update(): Promise<void>
Returns: resolves after re-render completes
viewcontroller.triggerLoad() #
Triggered before the first render call
triggerLoad(): any
viewcontroller.triggerMounted() #
Triggered after the first render call completed
triggerMounted(): any
viewcontroller.triggerUpdate(old,vdom) #
Triggered when the DOM content is updated
triggerUpdate(old: VirtualDOM, vdom: VirtualDOM): any
viewcontroller.triggerUnload() #
Triggered when after calling destroy()
triggerUnload(): any
viewcontroller.render() #
When rendering occurs, call to return the vdom object that needs to be rendered
render(): RenderResult
viewcontroller.appendTo(parent) #
appendTo(parent: View): View
@override
viewcontroller.afterTo(prev) #
Append the rendered DOM to a parent view.
afterTo(prev: View): View
@override
viewcontroller.destroy() #
Insert the rendered DOM after a previous view. Note: Do not proactively call this method
destroy()
@override
createElement(Type,props,...children) #
Creates a virtual DOM element from JSX syntax
createElement(Type: DOMConstructor<T> | JSX.IntrinsicElementsName, props: Dict | null, children: any[]): VirtualDOM
Returns: A VirtualDOM instance
Type parameters: T
VDom #
Typed shorthand for a VirtualDOM with a specific DOM implementation.
type VDom<T extends DOM = DOM> = VirtualDOM<T>
RenderData #
Data that can produce visible output in a virtual DOM render result.
type RenderData = VirtualDOM | string
RenderNode #
A renderable value or an empty value that produces no output.
type RenderNode = RenderData | null | undefined | void
RenderResult #
A single render node or a list of sibling render nodes.
type RenderResult = RenderNode[] | RenderNode