Skip to content

Latest commit

 

History

History
142 lines (102 loc) · 3.94 KB

component_api.md

File metadata and controls

142 lines (102 loc) · 3.94 KB

Component API

The base API is mixed into the Component prototype.

What is a Component?

A Component is just a constructor with properties mixed into its prototype. It comes with a set of basic functionality such as event handling and Component registration.

Each Component definition mixes in a set of custom properties which describe its behavior.

When a Component is attached to a DOM node, a new instance of that Component is created. Each Component instance references the DOM node via its node property.

A Component instance cannot be referenced directly; it communicates with other components via events.

flight.component(...)

flight.component accepts any number of mixin functions and returns a new Component constructor with those mixins applied to its prototype.

Each Component definition should include a function declaration describing its basic behavior (we can think of this function as the Component's core mixin). By passing this function to defineComponent we can define a simple Component: