Skip to main content
Version: 2.2.0

Composition – durandal/composition

caution

The interface documentation for this module is incomplete. Declarations may be missing or invalid.

The composition module encapsulates all functionality related to visual composition.

Variables​

current​

current: CompositionTransaction

Represents the currently executing composition transaction.

defaultTransitionName​

defaultTransitionName: string | null = null

The name of the transition to use in all compositions.

composeBindings (internal)​

composeBindings: string[] = false

An array of all the binding handler names (includeing :) that trigger a composition.

Functions​

addBindingHandler​

addBindingHandler(name: string, config?, initOptionsFactory?: Function): void

Registers a binding handler that will be invoked when the current composition transaction is complete.

  • (param) name – The name of the binding handler.
  • (param) config – The binding handler instance. If none is provided, the name will be used to look up an existing handler which will then be converted to a composition handler.
  • (param) initOptionsFactory – If the registered binding needs to return options from its init call back to knockout, this function will server as a factory for those options. It will receive the same parameters that the init function does.

compose​

compose(element: HTMLElement, settings, bindingContext?: ko.BindingContext, fromBinding?: boolean): 

Initiates a composition.

  • element – The DOMElement or knockout virtual element that serves as the parent for the composition.
  • settings – The composition settings.
  • bindingContext – The current binding context.
  • (internal param) fromBinding

convertTransitionToModuleId​

convertTransitionToModuleId(name: string): string

Converts a transition name to its moduleId.

  • (param) name – The name of the transtion.
  • returns – The moduleId.

defaultStrategy​

defaultStrategy(context: CompositionContext): JQueryPromise<unknown>

Eecutes the default view location strategy.

  • (param) context – The composition context containing the model and possibly existing viewElements.
  • returns – A promise for the view.

getParts​

getParts(elements: HTMLElement | HTMLElement[]): Record<string, HTMLElement>

Gets an object keyed with all the elements that are replacable parts, found within the supplied elements. The key will be the part name and the value will be the element itself.

  • (param) elements – The element(s) to search for parts.
  • returns – An object keyed by part.

bindAndShow (internal)​

bindAndShow(child, element, context, skipActivation): void

cloneNodes (internal)​

cloneNodes<T extends Node[]>(nodesArray: T): T

finalize (internal)​

finalize(context: CompositionContext, element: HTMLElement): void

getSettings (internal)​

getSettings(valueAccessor: () => unknown, element: HTMLElement)

executeStrategy (internal)​

executeStrategy(context: CompositionContext, element: HTMLElement): void

inject (internal)​

inject(context: CompositionContext, element: HTMLElement

Interfaces​

CompositionContext​

mode: string
parent: HTMLElement
activeView: HTMLElement
triggerAttach(): void
bindingContext?: KnockoutBindingContext
cacheViews?: boolean
viewElements?: HTMLElement[]
model?
view?
area?: string
preserveContext?: boolean
activate?: boolean
strategy?: (context: CompositionContext) => JQueryPromise<HTMLElement>>
composingNewView: boolean
child: HTMLElement
binding?: (child: HTMLElement, parent: HTMLElement, context:CompositionContext) => void
attached?: (child: HTMLElement, parent: HTMLElement, context:CompositionContext) => void
compositionComplete?: (child: HTMLElement, parent: HTMLElement, context:CompositionContext) => void
transition?: string

CompositionTransaction​

complete(callback: Function): void
Registers a callback which will be invoked when the current composition transaction has completed. The transaction includes all parent and children compositions.
  • (param) callback – The callback to be invoked when composition is complete.