Function
| Static Public Summary | ||
| public |
Clears all saved containers. |
|
| public |
composeContainers(root: Element | Container, containers: ...Element | Container | String): Container Compose a container from containers or DOM elements. |
|
| public |
createContainer(domElement: Element, initialState: Object, reducers: ...Function): Container Create a new Container instance with optional initial state and n reducers. |
|
| public |
Generates a unique hex ID for Container instances. |
|
| public |
fetchContainer(arg: String | Element | Object): class Container Fetch a saved container by container ID, DOM element, or by a container instance. |
|
| public |
forEachContainer(fn: Function, scope: Object) Execute a function for each container. |
|
| public |
getAllContainers(): MapIterator<String, Container> Returns an interator for all containers. |
|
| public |
getContainerData(arg: Container | Element | String): Object Returns immutable private stardux data for a given input. |
|
| public |
makeContainer(domElement: Element): Container Creates a or returns a new Container instance from a given DOM element. |
|
| public |
realignContainerTree(container: Container, recursive: Boolean, forceOrphanRestoration: Boolean) Realign container DOM tree by removing containers not found in container DOM tree. |
|
| public |
Removes a container from the internal tree. |
|
| public |
replaceDOMElement(container: Container, domElement: Element): Container Replace container element with another. |
|
| public |
restoreContainerFromJSON(json: Object, initialState: Object, reducers: ...Function): Container Create or restore a Container instance from a JSON object with an optional state object a reducers. |
|
| public |
restoreOrphanedTree(container: Container | Element, recursive: Boolean) Restores orphaned children containers still attached to a container. |
|
| public |
saveContainer(container: Container | Element): Boolean Save a container to the known containers map. |
|
| public |
traverseContainer(container: Container, fn: Function, scope: Object) Traverse a container's tree recursively. |
|
Static Public
public clearContainers(): undefined source
import {clearContainers} from 'stardux/src/index.js'Clears all saved containers. This will call removeContainer for every saved container.
public composeContainers(root: Element | Container, containers: ...Element | Container | String): Container source
import {composeContainers} from 'stardux/src/index.js'Compose a container from containers or DOM elements. If a Container or Element is given as first argument then it is treated as the root and all subsequent arguments are treated as direct descendants of the root. If the second argument is an array or an "array like" object then it is treated as direct descendants of the root and all subsequent arguments are ignored. If an array or "array like" object is passed as the first argument a new root container is created and the first argument is treated as direct descendants of the newly created root container. The root container, newly created or restored is returned.
Example:
const a = createContainer()
const b = createContainer()
const composed = composeContainers([a, b])
const a = createContainer()
const b = createContainer()
const c = createContainer()
const composed = composeContainers(a, [b, c])
public createContainer(domElement: Element, initialState: Object, reducers: ...Function): Container source
import {createContainer} from 'stardux/src/index.js'Create a new Container instance with optional initial state and n reducers.
Example:
const container = createContainer()
const container = createContainer(domElement)
const container = createContainer(domElement, {value: 0})
const container = createContainer(domElement, {value: 0}, (state = {}, action) => {
if (UPATE == action.type) {
return {
value: state.action + action.data.value
}
}
})
public createContainerUid(): String source
import {createContainerUid} from 'stardux/src/index.js'Generates a unique hex ID for Container instances.
Example:
const id = createContainerUid()
public fetchContainer(arg: String | Element | Object): class Container source
import {fetchContainer} from 'stardux/src/index.js'Fetch a saved container by container ID, DOM element, or by a container instance.
Return:
| class Container |
Example:
const container = fetchContainer(id)
const container = fetchContainer(domElement)
const container = fetchContainer({id: id})
public forEachContainer(fn: Function, scope: Object) source
import {forEachContainer} from 'stardux/src/index.js'Execute a function for each container.
Example:
forEachContainer(container => {
console.log(container)
})
public getAllContainers(): MapIterator<String, Container> source
import {getAllContainers} from 'stardux/src/index.js'Returns an interator for all containers.
Example:
const it = getAllContainers()
for (let pair of [ ...it ])
console.log(pair)
public getContainerData(arg: Container | Element | String): Object source
import {getContainerData} from 'stardux/src/index.js'Returns immutable private stardux data for a given input. Input can be a container, an Element, or a string representing a container ID. If data is not found then null is returned.
Example:
const data = getContainerData(container)
const data = getContainerData(container)
const data = getContainerData(id)
public makeContainer(domElement: Element): Container source
import {makeContainer} from 'stardux/src/index.js'Creates a or returns a new Container instance from a given DOM element.
If a DOM element is already associated with a container then the container is just returned, otherwise a new one is created.
Params:
| Name | Type | Attribute | Description |
| domElement | Element |
Example:
const container = makeContainer(document.body)
public realignContainerTree(container: Container, recursive: Boolean, forceOrphanRestoration: Boolean) source
import {realignContainerTree} from 'stardux/src/index.js'Realign container DOM tree by removing containers not found in container DOM tree. If recursive is set to true then realignment is applied to all subsequent child containers. If forceOrphanRestoration is set to true then orphan containers are restored.
public removeContainer(arg: String | Container | Element, recursive: Boolean): Boolean source
import {removeContainer} from 'stardux/src/index.js'Removes a container from the internal tree. The container is also removed from its parent if it is attched to one. A string ID, DOM element, or Container may be used as an argument.
Example:
removeContainer(id)
removeContainer(domElement)
removeContainer({id: id})
public replaceDOMElement(container: Container, domElement: Element): Container source
import {replaceDOMElement} from 'stardux/src/index.js'Replace container element with another. This will remove all children containers and realign the container tree.
public restoreContainerFromJSON(json: Object, initialState: Object, reducers: ...Function): Container source
import {restoreContainerFromJSON} from 'stardux/src/index.js'Create or restore a Container instance from a JSON object with an optional state object a reducers.
Containers are created if they do not already exist internally.
Example:
const container = restoreContainerFromJSON(json)
const container = restoreContainerFromJSON(json, {value: 0})
const container = restoreContainerFromJSON(json, {value: 0}, ...reducers)
public restoreOrphanedTree(container: Container | Element, recursive: Boolean) source
import {restoreOrphanedTree} from 'stardux/src/index.js'Restores orphaned children containers still attached to a container. An orphan container is a container who belongs to a set of containers and it's DOM element is not attched to a DOM tree (The parent container's DOM element).
public saveContainer(container: Container | Element): Boolean source
import {saveContainer} from 'stardux/src/index.js'Save a container to the known containers map. A DOM element may be passed if it has been claimed by a Container instance.
Example:
saveContainer(container)
saveContainer(domElement)
public traverseContainer(container: Container, fn: Function, scope: Object) source
import {traverseContainer} from 'stardux/src/index.js'Traverse a container's tree recursively.
Example:
traverseContainer(container, child => {
console.log(child)
})