Module Binding

Index

Variables

Interfaces

Classes

Functions

Variables

dynamicObservableMixin: { addProperty(name: string, value: any): void; bind(name: string, action: any): Function; getProperty(name: string): any; notify(name: string, newValue: string, oldValue: string): WinJS.Promise<any>; removeProperty(name: string): any; setProperty(name: string, value: any): any; unbind(name: string, action: Function): any; updateProperty(name: string, value: any): WinJS.Promise<any>; }

Allows you to add bindable properties dynamically.

public addProperty()

Adds a property with change notification to this object, including a ECMAScript5 property definition.

.name.name: string

.value.value: any

public bind(): Function

Links the specified action to the property specified in the name parameter. This function is invoked when the value of the property may have changed. It is not guaranteed that the action will be called only when a value has actually changed, nor is it guaranteed that the action will be called for every value change. The implementation of this function coalesces change notifications, such that multiple updates to a property value may result in only a single call to the specified action.

Returns

Function

This object is returned.

.action.action: any

.name.name: string

public getProperty(): any

Gets a property value by name.

Returns

any

The value of the property as an observable object.

.name.name: string

public notify(): Promise

Notifies listeners that a property value was updated.

Returns

Promise

A promise that is completed when the notifications are complete.

.name.name: string

.newValue.newValue: string

.oldValue.oldValue: string

public removeProperty(): any

Removes a property value.

Returns

any

This object is returned.

.name.name: string

public setProperty(): any

Updates a property value and notifies any listeners.

Returns

any

This object is returned.

.name.name: string

.value.value: any

public unbind(): any

Removes one or more listeners from the notification list for a given property.

Returns

any

This object is returned.

.action.action: Function

.name.name: string

public updateProperty(): Promise

Updates a property value and notifies any listeners.

Returns

Promise

A promise that completes when the notifications for this property change have been processed. If multiple notifications are coalesced, the promise may be canceled or the value of the promise may be updated. The fulfilled value of the promise is the new value of the property for which the notifications have been completed.

.name.name: string

.value.value: any

mixin: { addProperty(name: string, value: any): any; bind(name: string, action: any): Function; getProperty(name: string): any; notify(name: string, newValue: string, oldValue: string): WinJS.Promise<any>; removeProperty(name: string): any; setProperty(name: string, value: any): any; unbind(name: string, action: Function): any; updateProperty(name: string, value: any): WinJS.Promise<any>; }

Provides a standard implementation of the bindable contract, as well as a basic storage mechanism that participates in change notification and an asynchronous notification implementation.

public addProperty(): any

Adds a property to the object. The property includes change notification and an ECMAScript 5 property definition .

Returns

any

This object is returned.

.name.name: string

.value.value: any

public bind(): Function

Links the specified action to the property specified in the name parameter. This function is invoked when the value of the property may have changed. It is not guaranteed that the action will be called only when a value has actually changed, nor is it guaranteed that the action will be called for every value change. The implementation of this function coalesces change notifications, such that multiple updates to a property value may result in only a single call to the specified action.

Returns

Function

This object is returned.

.action.action: any

.name.name: string

public getProperty(): any

Gets a property value by name.

Returns

any

The value of the property as an observable object.

.name.name: string

public notify(): Promise

Notifies listeners that a property value was updated.

Returns

Promise

A promise that is completed when the notifications are complete.

.name.name: string

.newValue.newValue: string

.oldValue.oldValue: string

public removeProperty(): any

Removes a property value.

Returns

any

This object is returned.

.name.name: string

public setProperty(): any

Updates a property value and notifies any listeners.

Returns

any

This object is returned.

.name.name: string

.value.value: any

public unbind(): any

Removes one or more listeners from the notification list for a given property.

Returns

any

This object is returned.

.action.action: Function

.name.name: string

public updateProperty(): Promise

Updates a property value and notifies any listeners.

Returns

Promise

A promise that completes when the notifications for this property change have been processed. If multiple notifications are coalesced, the promise may be canceled or the value of the promise may be updated. The fulfilled value of the promise is the new value of the property for which the notifications have been completed.

.name.name: string

.value.value: any

observableMixin: { bind(name: string, action: Function): any; notify(name: string, newValue: any, oldValue: any): WinJS.Promise<any>; unbind(name: string, action: Function): any; }

Provides functions that can make an object observable.

public bind(): any

Links the specified action to the property specified in the name parameter. This function is invoked when the value of the property may have changed. It is not guaranteed that the action will be called only when a value has actually changed, nor is it guaranteed that the action will be called for every value change. The implementation of this function coalesces change notifications, such that multiple updates to a property value may result in only a single call to the specified action.

Returns

any

A reference to this observableMixin object.

.action.action: Function

.name.name: string

public notify(): Promise

Notifies listeners that a property value was updated.

Returns

Promise

A promise that is completed when the notifications are complete.

.name.name: string

.newValue.newValue: any

.oldValue.oldValue: any

public unbind(): any

Removes one or more listeners from the notification list for a given property.

Returns

any

This object is returned.

.action.action: Function

.name.name: string

optimizeBindingReferences: boolean

Determines whether or not binding should automatically set the ID of an element. This property should be set to true in apps that use WinJS (WinJS) binding.

Functions

addClassOneTime(source: any, sourceProperties: Array<any>, dest: HTMLElement)

Adds a CSS class from the specified path of the source object to a destination object.

Parameters

  • source: any

    The source object that has the class to copy.

  • sourceProperties: Array<any>

    The path on the source object to the source class.

  • dest: HTMLElement

    The destination object.

as(data: U): U

Returns an observable object. This may be an observable proxy for the specified object, an existing proxy, or the specified object itself if it directly supports observation.

Parameters

  • data: U

    The object to observe.

Returns

U

The observable object.

bind(observable: any, bindingDescriptor: any): any

Binds to one or more properties on the observable object or or on child values of that object.

Parameters

  • observable: any

    The object to bind to.

  • bindingDescriptor: any

    An object literal containing the binding declarations. Binding declarations take the form: { propertyName: (function | bindingDeclaration), ... }.

Returns

any

An object that contains at least a "cancel" field, which is a function that removes all bindings associated with this bind request.

converter(convert: Function): Function

Creates a default binding initializer for binding between a source property and a destination property with the specified converter function that is executed on the value of the source property.

Parameters

  • convert: Function

    The conversion function that takes the source property and produces a value that is set to the destination property. This function must be accessible from the global namespace.

Returns

Function

The binding initializer.

defaultBind(source: any, sourceProperties: any, dest: any, destProperties: any): any

Creates a one-way binding between the source object and the destination object. Warning Do not attempt to bind data to the ID of an HTML element.

Parameters

  • source: any

    The source object.

  • sourceProperties: any

    The path on the source object to the source property.

  • dest: any

    The destination object.

  • destProperties: any

    The path on the destination object to the destination property.

Returns

any

An object with a cancel method that is used to coalesce bindings.

define(data: any): Function

Creates a new constructor function that supports observability with the specified set of properties.

Parameters

  • data: any

    The object to use as the pattern for defining the set of properties.

Returns

Function

A constructor function with 1 optional argument that is the initial state of the properties.

expandProperties(shape: any): any

Wraps the specified object so that all its properties are instrumented for binding. This is meant to be used in conjunction with the binding mixin.

Parameters

  • shape: any

    The specification for the bindable object.

Returns

any

An object with a set of properties all of which are wired for binding.

initializer(customInitializer: Function): Function

Marks a custom initializer function as being compatible with declarative data binding.

Parameters

  • customInitializer: Function

    The custom initializer to be marked as compatible with declarative data binding.

Returns

Function

The input customInitializer.

notify(name: string, newValue: string, oldValue: string): Promise

Notifies listeners that a property value was updated.

Parameters

  • name: string

    The name of the property that is being updated.

  • newValue: string

    The new value for the property.

  • oldValue: string

    The old value for the property.

Returns

Promise

A promise that is completed when the notifications are complete.

oneTime(source: any, sourceProperties: any, dest: any, destProperties: any): any

Sets the destination property to the value of the source property.

Parameters

  • source: any

    The source object.

  • sourceProperties: any

    The path on the source object to the source property.

  • dest: any

    The destination object.

  • destProperties: any

    The path on the destination object to the destination property.

Returns

any

An object with a cancel method that is used to coalesce bindings.

processAll(rootElement?: Element, dataContext?: any, skipRoot?: boolean, bindingCache?: any, defaultInitializer?: Function): Promise

Binds the values of an object to the values of a DOM element that has the data-win-bind attribute. If multiple DOM elements are to be bound, you must set the attribute on all of them. See the example below for details.

Parameters

  • rootElement?: Element optional

    Optional. The element at which to start traversing to find elements to bind to. If this parameter is omitted, the entire document is searched.

  • dataContext?: any optional

    The object that contains the values to which the DOM element should be bound.

  • skipRoot?: boolean optional

    If true, specifies that only the children of rootElement should be bound, otherwise rootElement should be bound as well.

  • bindingCache?: any optional

    The cached binding data.

  • defaultInitializer?: Function optional

    The binding initializer to use in the case that one is not specified in a binding expression. If not provided, the behavior is the same as Binding.defaultBind.

Returns

Promise

A Promise that completes when every item that contains the data-win-bind attribute has been processed and the update has started.

setAttribute(source: any, sourceProperties: Array<any>, dest: Element, destProperties: Array<any>): any

Creates a one-way binding between the source object and an attribute on the destination element.

Parameters

  • source: any

    The source object.

  • sourceProperties: Array<any>

    The path on the source object to the source property.

  • dest: Element

    The destination object.

  • destProperties: Array<any>

    The path on the destination object to the destination property. This must be a single name.

Returns

any

An object with a cancel() method that is used to coalesce bindings.

setAttributeOneTime(source: any, sourceProperties: Array<any>, dest: Element, destProperties: Array<any>)

Sets an attribute on the destination element to the value of the source property.

Parameters

  • source: any

    The source object.

  • sourceProperties: Array<any>

    The path on the source object to the source property.

  • dest: Element

    The destination object.

  • destProperties: Array<any>

    The path on the destination object to the destination property. This must be a single name.

unwrap(data: any): any

Returns the original (non-observable) object is returned if the specified object is an observable proxy,

Parameters

  • data: any

    The object for which to retrieve the original value.

Returns

any

If the specified object is an observable proxy, the original object is returned, otherwise the same object is returned.