Home Manual Reference Source Test Repository
import {Container} from 'stardux/src/index.js'
public class | source

Container

Container class.

Constructor Summary

Public Constructor
public

constructor(domElement: Element | String)

Container constructor.

Member Summary

Public Members
public get

Child containers

public get

Container DOM element.

public get

Container id.

public get

Internal contents of the container

public get

Getter to return parent container if available.

public get

Copy of the internal state object.

Method Summary

Public Methods
public

appendChild(child: Container | Element | Text | String, update: Boolean, realign: Boolean): Container

Append a child container.

public

contains(container: Container | Element, recursive: Boolean): Boolean

Predicate to determine if a container or its DOM element is a child of the container.

public

Extend view model.

public

dispatch(type: Mixed, data: Object, args: Object): Container

Dispatch an event with type, optional data and optional arguments to the internal redux store.

public

pipe(container: Container): Container

Pipe container updates to a given container.

public

removeChild(child: Container | Element, update: Boolean, realign: Boolean): Container

Remove a child container.

public

render(domElement: Element): Container

Render container to a DOM element.

public

replaceChildren(children: Array<Container | Element>): Container

Replace child tree with new children.

public

Converts container to a JSON serializable object.

public

Returns the string reprenstation of this container.

public

unpipe(container: Container): Container

Unpipe container updates for a given container.

public

update(data: Object, propagate: Boolean): Container

Updates container and all child containers.

public

use(plugins: ...Function): Container

Consume reducer middleware.

public

Returns the associated value of the container.

Public Constructors

public constructor(domElement: Element | String) source

Container constructor.

Params:

NameTypeAttributeDescription
domElement Element | String
...reducers Function

Public Members

public get children: Array<Container>: * source

Child containers

Return:

Array<Container>

public get domElement: Element source

Container DOM element.

public get id: String source

Container id.

public get innerContents: String source

Internal contents of the container

public get parent: Container | null source

Getter to return parent container if available. Parent is determined with DOM traversal up the tree. A container can be considered orphaned if it doesn't have a parent DOM element.

public get state: Object source

Copy of the internal state object.

Public Methods

public appendChild(child: Container | Element | Text | String, update: Boolean, realign: Boolean): Container source

Append a child container. A child may be an instance of a Container, Element, Text, or a string. Containers are derived from their input and will cause a DOM tree to be restructured.

Params:

NameTypeAttributeDescription
child Container | Element | Text | String
update Boolean
  • optional
realign Boolean
  • optional

Return:

Container

Example:

  container.appendChild(child)

public contains(container: Container | Element, recursive: Boolean): Boolean source

Predicate to determine if a container or its DOM element is a child of the container.

Params:

NameTypeAttributeDescription
container Container | Element
recursive Boolean
  • optional

Return:

Boolean

Example:

  if (container.contains(child)) {
    ...
  }

public define(model: Object): Container source

Extend view model.

Params:

NameTypeAttributeDescription
model Object

Return:

Container

Example:

Extend current state model.
  container.define({value: 0})

public dispatch(type: Mixed, data: Object, args: Object): Container source

Dispatch an event with type, optional data and optional arguments to the internal redux store.

Params:

NameTypeAttributeDescription
type Mixed
data Object
  • optional
args Object
  • optional

Return:

Container

Example:

Dispatch an action with type and optional data and action argument.
  container.dispatch({
    type: 'MY_ACTION',
    data: {value: 123},
    propagate: false
  })

public pipe(container: Container): Container source

Pipe container updates to a given container.

Params:

NameTypeAttributeDescription
container Container

Return:

Container

container

Example:

 containerA.pipe(containerB)

public removeChild(child: Container | Element, update: Boolean, realign: Boolean): Container source

Remove a child container. A child may be an instance of a Container or Element. Containers are derived from their input and will cause a DOM tree to be restructured.

Params:

NameTypeAttributeDescription
child Container | Element
update Boolean
  • optional
realign Boolean
  • optional

Return:

Container

Example:

  container.removeChild(child)

public render(domElement: Element): Container source

Render container to a DOM element.

Params:

NameTypeAttributeDescription
domElement Element

Return:

Container

Example:

Render container to a given domElement.
  container.render(document.body)

public replaceChildren(children: Array<Container | Element>): Container source

Replace child tree with new children.

Params:

NameTypeAttributeDescription
children Array<Container | Element>

Return:

Container

Example:

 container.replaceChildren([childA, childB, createContainer()])

public toJSON(): Object source

Converts container to a JSON serializable object.

Return:

Object

public toString(): String source

Returns the string reprenstation of this container.

Return:

String

public unpipe(container: Container): Container source

Unpipe container updates for a given container.

Params:

NameTypeAttributeDescription
container Container

Return:

Container

container

Example:

 containerA.unpipe(containerB)

public update(data: Object, propagate: Boolean): Container source

Updates container and all child containers.

Params:

NameTypeAttributeDescription
data Object
  • optional

New state data

propagate Boolean
  • optional

Propagate updates to child containers.

Return:

Container

Example:

Update container and its children
  container.update({value: 0})
Update only container and not its children
  container.update({value: 0}, false)

public use(plugins: ...Function): Container source

Consume reducer middleware.

Params:

NameTypeAttributeDescription
plugins ...Function

Return:

Container

Example:

Install reducer middleware plugin.
  container.use((state = {}, action) => { ... })

public valueOf(): Element source

Returns the associated value of the container.

Return:

Element