Home Reference Source
public class | source

Module

The main class, used to create a Modux module. You can think of this as the main application

Constructor Summary

Public Constructor
public

Creates an instance of Module

Member Summary

Public Members
public

store: Store

Contains a new instance of @crispcode/pushstore which is passed on to all components.

Method Summary

Public Methods
public

addDependency(name: String, dependency: Component): Module

A method used to add components to the Module

public

bootstrap(element: HTMLElement, component: Component)

Initializes the Module on a specific HTMLElement and loads the specified Component for it

public

createComponent(node: HTMLElement)

Renders an HTMLElement to a Component as if it was a part of this module

public

Destroy the current module.

public

A method used to remove components from the Module

Public Constructors

public constructor(name: String) source

Creates an instance of Module

Params:

NameTypeAttributeDescription
name String
  • optional

A unique name for the module, for easier management

Public Members

public store: Store source

Contains a new instance of @crispcode/pushstore which is passed on to all components. See https://www.npmjs.com/package/@crispcode/pushstore

Public Methods

public addDependency(name: String, dependency: Component): Module source

A method used to add components to the Module

Params:

NameTypeAttributeDescription
name String

The name under which the Component will be known as

dependency Component

The Component to be added

Return:

Module

The instance of Module

public bootstrap(element: HTMLElement, component: Component) source

Initializes the Module on a specific HTMLElement and loads the specified Component for it

Params:

NameTypeAttributeDescription
element HTMLElement

The HTMLElement used as the wrapper for the Module

component Component

The Component to be used as the main Component

public createComponent(node: HTMLElement) source

Renders an HTMLElement to a Component as if it was a part of this module

Params:

NameTypeAttributeDescription
node HTMLElement

The HTMLElement to be converted to a Component

public destroy() source

Destroy the current module. This will also destroy all the components created and disconnect the MutationObserver

public removeDependency(name: String): Module source

A method used to remove components from the Module

Params:

NameTypeAttributeDescription
name String

The name of the Component to be removed

Return:

Module

The instance of Module