Javascript API
interfaces
Component

Interface: Component

Component is a base class for all other components so all components have the following properties, methods, and events in addition to their own.

Hierarchy

Properties

componentType

Readonly componentType: string

The component's type. E.g. "View", "Text", "Button", "Page", etc.


id

Readonly id: number

Every Component is assigned a unique numerical id that cannot be changed. Components can be looked up by id using the get function.


name

name: undefined | string

Every Component can have a user-assigned name. It can be anything and is not guaranteed to be unique. Components can be looked up by name using the get function.

Methods

clone

clone(): Component

Create an exact duplicate of a component.

The clone must be added to a container with appendChild to be visible.

Returns

Component

Example

const clone = view.clone();
clone.x = 100;
clone.y = 100;
view.page.appendChild(clone);

on

on<K>(type, listener, options?): () => void

Add an event listener to the component.

Type parameters

NameType
Kextends keyof EventHandlersEventMap

Parameters

NameType
typeK
listener(event: EventHandlersEventMap[K]) => any
options?EventListenerOptions

Returns

fn

Returns a function that removes the event listener.

▸ (): void

Add an event listener to the component.

Returns

void

Returns a function that removes the event listener.