Skip to content
Kory Nunn edited this page Jun 11, 2019 · 3 revisions

var someComponent = fastn('myComponent');

A fastn component is an object that represents a chunk of UI.

A component is an instance of EventEmitter, and is passed through component constructors to have features added or modified.

Methods:

All component methods are overridable.

attach(object or Model, firmness) -> component

Attaches the component to the provided object.

If a Model is passed, attach will use the object that the model is currently attached to.

If a firmness is provided, the component will only be attached if the firmness is equal to or higher than that which it is currently attached at.

Returns the component.

detach(firmness) -> component

Detaches the component from the model it is attached to

If a firmness is provided, the component will only be detached if the firmness is equal to or higher than that which it is currently attached at.

Returns the component.

scope() -> Model

Returns a Model which is attached to the object that the component is attached to.

destroy() -> component

Destroys a component, potentially freeing memory and removing event handlers.

Returns the component.

destroyed() -> boolean

Returns whether the component is destroyed

binding(nothing or binding or path)

If called with no arguments, will return the components current binding.

If called with a path or binding, will set the components binding.

setProperty(key, nothing or property) -> component

Sets a key on the component to be the passed property.

Returns the component.

clone() -> new component

returns a clone of the component.

children()

returns a new array containing all of the components children.

extend(componentType, settings, children...) -> compnent

passes the component through the requested component constructor.

is(componentType) -> boolean

Returns whether the component has been extended with the given type

Unimplemented Methods

The base fastn component doesn't implement some properties that are expected for normal operation. Most base components implement these properties, but if you want to create a totally custom component, you may have to implement them

render() -> component

Renderes the component.

render must:

  • assign an object of some kind to component.element (for example, a DOM node).
  • emit('render')
Clone this wiki locally