Class ListBaseWithMutators

Represents a base class for normal list modifying operations.

Hierarchy

Index

Properties

Methods

Properties

public dataSource: IListDataSource

Gets the IListDataSource for the list. The only purpose of this property is to adapt a List to the data model that is used by ListView and FlipView.

Methods

public addEventListener(type: string, listener: Function, useCapture?: boolean)

Adds an event listener to the control.

Parameters

  • type: string

    The type (name) of the event.

  • listener: Function

    The listener to invoke when the event gets raised.

  • useCapture?: boolean optional

    If true, initiates capture, otherwise false.

public addEventListener(type: string, listener: Function, useCapture?: boolean)

Adds an event listener to the control.

Parameters

  • type: string

    The type (name) of the event.

  • listener: Function

    The listener to invoke when the event gets raised.

  • useCapture?: boolean optional

    If true, initiates capture, otherwise false.

public bind(name: string, action: Function): 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.

Parameters

  • name: string

    The name of the property to which to bind the action.

  • action: Function

    The function to invoke asynchronously when the property may have changed.

Returns

any

A reference to this observableMixin object.

public bind(name: string, action: Function): 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.

Parameters

  • name: string

    The name of the property to which to bind the action.

  • action: Function

    The function to invoke asynchronously when the property may have changed.

Returns

any

A reference to this observableMixin object.

public concat(item?: Array<T>): Array<T>

Returns a new list consisting of a combination of two arrays.

Parameters

  • item?: Array<T> optional

    Additional items to add to the end of the list.

Returns

Array<T>

An array containing the concatenation of the list and any other supplied items.

public concat(item?: Array<T>): Array<T>

Returns a new list consisting of a combination of two arrays.

Parameters

  • item?: Array<T> optional

    Additional items to add to the end of the list.

Returns

Array<T>

An array containing the concatenation of the list and any other supplied items.

public createFiltered(predicate: (x: T) => boolean): FilteredListProjection

Creates a live filtered projection over this list. As the list changes, the filtered projection reacts to those changes and may also change.

Parameters

  • predicate: (x: T) => boolean

    A function that accepts a single argument. The createFiltered function calls the callback with each element in the list. If the function returns true, that element will be included in the filtered list. This function must always return the same results, given the same inputs. The results should not depend on values that are subject to change. You must call notifyMutated each time an item changes. Do not batch change notifications.

Returns

FilteredListProjection

A filtered projection over the list.

public createFiltered(predicate: (x: T) => boolean): FilteredListProjection

Creates a live filtered projection over this list. As the list changes, the filtered projection reacts to those changes and may also change.

Parameters

  • predicate: (x: T) => boolean

    A function that accepts a single argument. The createFiltered function calls the callback with each element in the list. If the function returns true, that element will be included in the filtered list. This function must always return the same results, given the same inputs. The results should not depend on values that are subject to change. You must call notifyMutated each time an item changes. Do not batch change notifications.

Returns

FilteredListProjection

A filtered projection over the list.

public createGrouped(groupKey: (x: T) => string, groupData: (x: T) => any, groupSorter: (left: string, right: string) => number): GroupedSortedListProjection

Creates a live grouped projection over this list. As the list changes, the grouped projection reacts to those changes and may also change. The grouped projection sorts all the elements of the list to be in group-contiguous order. The grouped projection also contains a .groups property, which is a List representing the groups that were found in the list.

Parameters

  • groupKey: (x: T) => string

    A function that accepts a single argument. The function is called with each element in the list, the function should return a string representing the group containing the element. This function must always return the same results, given the same inputs. The results should not depend on values that are subject to change. You must call notifyMutated each time an item changes. Do not batch change notifications.

  • groupData: (x: T) => any

    A function that accepts a single argument. The function is called once, on one element per group. It should return the value that should be set as the data of the .groups list element for this group. The data value usually serves as summary or header information for the group.

  • groupSorter: (left: string, right: string) => number

    A function that accepts two arguments. The function is called with pairs of group keys found in the list. It must return one of the following numeric values: negative if the first argument is less than the second (sorted before), zero if the two arguments are equivalent, positive if the first argument is greater than the second (sorted after).

Returns

GroupedSortedListProjection

A grouped projection over the list.

public createGrouped(groupKey: (x: T) => string, groupData: (x: T) => any, groupSorter: (left: string, right: string) => number): GroupedSortedListProjection

Creates a live grouped projection over this list. As the list changes, the grouped projection reacts to those changes and may also change. The grouped projection sorts all the elements of the list to be in group-contiguous order. The grouped projection also contains a .groups property, which is a List representing the groups that were found in the list.

Parameters

  • groupKey: (x: T) => string

    A function that accepts a single argument. The function is called with each element in the list, the function should return a string representing the group containing the element. This function must always return the same results, given the same inputs. The results should not depend on values that are subject to change. You must call notifyMutated each time an item changes. Do not batch change notifications.

  • groupData: (x: T) => any

    A function that accepts a single argument. The function is called once, on one element per group. It should return the value that should be set as the data of the .groups list element for this group. The data value usually serves as summary or header information for the group.

  • groupSorter: (left: string, right: string) => number

    A function that accepts two arguments. The function is called with pairs of group keys found in the list. It must return one of the following numeric values: negative if the first argument is less than the second (sorted before), zero if the two arguments are equivalent, positive if the first argument is greater than the second (sorted after).

Returns

GroupedSortedListProjection

A grouped projection over the list.

public createSorted(sorter: (left: T, right: T) => number): SortedListProjection

Creates a live sorted projection over this list. As the list changes, the sorted projection reacts to those changes and may also change.

Parameters

  • sorter: (left: T, right: T) => number

    A function that accepts two arguments. The function is called with elements in the list. It must return one of the following numeric values: negative if the first argument is less than the second, zero if the two arguments are equivalent, positive if the first argument is greater than the second. This function must always return the same results, given the same inputs. The results should not depend on values that are subject to change. You must call notifyMutated each time an item changes. Do not batch change notifications.

Returns

SortedListProjection

A sorted projection over the list.

public createSorted(sorter: (left: T, right: T) => number): SortedListProjection

Creates a live sorted projection over this list. As the list changes, the sorted projection reacts to those changes and may also change.

Parameters

  • sorter: (left: T, right: T) => number

    A function that accepts two arguments. The function is called with elements in the list. It must return one of the following numeric values: negative if the first argument is less than the second, zero if the two arguments are equivalent, positive if the first argument is greater than the second. This function must always return the same results, given the same inputs. The results should not depend on values that are subject to change. You must call notifyMutated each time an item changes. Do not batch change notifications.

Returns

SortedListProjection

A sorted projection over the list.

public dispatchEvent(type: string, eventProperties: any): boolean

Raises an event of the specified type and with the specified additional properties.

Parameters

  • type: string

    The type (name) of the event.

  • eventProperties: any

    The set of additional properties to be attached to the event object when the event is raised.

Returns

boolean

true if preventDefault was called on the event.

public dispatchEvent(type: string, eventProperties: any): boolean

Raises an event of the specified type and with the specified additional properties.

Parameters

  • type: string

    The type (name) of the event.

  • eventProperties: any

    The set of additional properties to be attached to the event object when the event is raised.

Returns

boolean

true if preventDefault was called on the event.

public every(callback: (value: T, index: number, array: T[]) => boolean, thisArg?: any): boolean

Checks whether the specified callback function returns true for all elements in a list.

Parameters

  • callback: (value: T, index: number, array: T[]) => boolean

    A function that accepts up to three arguments. This function is called for each element in the list until it returns false or the end of the list is reached.

  • thisArg?: any optional

    An object to which the this keyword can refer in the callback function. If thisArg is omitted, undefined is used.

Returns

boolean

true if the callback returns true for all elements in the list.

public every(callback: (value: T, index: number, array: T[]) => boolean, thisArg?: any): boolean

Checks whether the specified callback function returns true for all elements in a list.

Parameters

  • callback: (value: T, index: number, array: T[]) => boolean

    A function that accepts up to three arguments. This function is called for each element in the list until it returns false or the end of the list is reached.

  • thisArg?: any optional

    An object to which the this keyword can refer in the callback function. If thisArg is omitted, undefined is used.

Returns

boolean

true if the callback returns true for all elements in the list.

public filter(callback: (value: T, index: number, array: T[]) => any, thisArg?: any): Array<T>

Returns the elements of a list that meet the condition specified in a callback function.

Parameters

  • callback: (value: T, index: number, array: T[]) => any

    A function that accepts up to three arguments. The function is called for each element in the list. This function must always return the same results, given the same inputs. The results should not depend on values that are subject to change. You must call notifyMutated each time an item changes. Do not batch change notifications.

  • thisArg?: any optional

    An object to which the this keyword can refer in the callback function. If thisArg is omitted, undefined is used.

Returns

Array<T>

An array containing the elements that meet the condition specified in the callback function.

public filter(callback: (value: T, index: number, array: T[]) => any, thisArg?: any): Array<T>

Returns the elements of a list that meet the condition specified in a callback function.

Parameters

  • callback: (value: T, index: number, array: T[]) => any

    A function that accepts up to three arguments. The function is called for each element in the list. This function must always return the same results, given the same inputs. The results should not depend on values that are subject to change. You must call notifyMutated each time an item changes. Do not batch change notifications.

  • thisArg?: any optional

    An object to which the this keyword can refer in the callback function. If thisArg is omitted, undefined is used.

Returns

Array<T>

An array containing the elements that meet the condition specified in the callback function.

public forEach(callback: (value: T, index: number, array: T[]) => void, thisArg?: any)

Calls the specified callback function for each element in a list.

Parameters

  • callback: (value: T, index: number, array: T[]) => void

    A function that accepts up to three arguments. The function is called for each element in the list. The arguments are as follows: value, index, array.

  • thisArg?: any optional

    An object to which the this keyword can refer in the callback function. If thisArg is omitted, undefined is used.

public forEach(callback: (value: T, index: number, array: T[]) => void, thisArg?: any)

Calls the specified callback function for each element in a list.

Parameters

  • callback: (value: T, index: number, array: T[]) => void

    A function that accepts up to three arguments. The function is called for each element in the list. The arguments are as follows: value, index, array.

  • thisArg?: any optional

    An object to which the this keyword can refer in the callback function. If thisArg is omitted, undefined is used.

public getAt(index: number): T in WinJS.Binding.ListBase<T>

Gets the value at the specified index.

Parameters

  • index: number

    The index of the value to get.

Returns

T in WinJS.Binding.ListBase<T>

The value at the specified index.

public getAt(index: number): T in WinJS.Binding.ListBase<T>

Gets the value at the specified index.

Parameters

  • index: number

    The index of the value to get.

Returns

T in WinJS.Binding.ListBase<T>

The value at the specified index.

public indexOf(searchElement: T in WinJS.Binding.ListBase<T>, fromIndex?: number): number

Gets the index of the first occurrence of the specified value in a list.

Parameters

  • searchElement: T in WinJS.Binding.ListBase<T>

    The value to locate in the list.

  • fromIndex?: number optional

    The index at which to begin the search. If fromIndex is omitted, the search starts at index 0.

Returns

number

The index of the first occurrence of a value in a list or -1 if not found.

public indexOf(searchElement: T in WinJS.Binding.ListBase<T>, fromIndex?: number): number

Gets the index of the first occurrence of the specified value in a list.

Parameters

  • searchElement: T in WinJS.Binding.ListBase<T>

    The value to locate in the list.

  • fromIndex?: number optional

    The index at which to begin the search. If fromIndex is omitted, the search starts at index 0.

Returns

number

The index of the first occurrence of a value in a list or -1 if not found.

public join(separator: string): string

Returns a string consisting of all the elements of a list separated by the specified separator string.

Parameters

  • separator: string

    A string used to separate the elements of a list. If this parameter is omitted, the list elements are separated with a comma.

Returns

string

The elements of a list separated by the specified separator string.

public join(separator: string): string

Returns a string consisting of all the elements of a list separated by the specified separator string.

Parameters

  • separator: string

    A string used to separate the elements of a list. If this parameter is omitted, the list elements are separated with a comma.

Returns

string

The elements of a list separated by the specified separator string.

public lastIndexOf(searchElement: T in WinJS.Binding.ListBase<T>, fromIndex: number): number

Gets the index of the last occurrence of the specified value in a list.

Parameters

  • searchElement: T in WinJS.Binding.ListBase<T>

    The value to locate in the list.

  • fromIndex: number

    The index at which to begin the search. If fromIndex is omitted, the search starts at the last index in the list.

Returns

number

The index of the last occurrence of a value in a list, or -1 if not found.

public lastIndexOf(searchElement: T in WinJS.Binding.ListBase<T>, fromIndex: number): number

Gets the index of the last occurrence of the specified value in a list.

Parameters

  • searchElement: T in WinJS.Binding.ListBase<T>

    The value to locate in the list.

  • fromIndex: number

    The index at which to begin the search. If fromIndex is omitted, the search starts at the last index in the list.

Returns

number

The index of the last occurrence of a value in a list, or -1 if not found.

public map(callback: (value: T, index: number, array: T[]) => G, thisArg?: any): Array<G>

Calls the specified callback function on each element of a list, and returns an array that contains the results.

Parameters

  • callback: (value: T, index: number, array: T[]) => G

    A function that accepts up to three arguments. The function is called for each element in the list.

  • thisArg?: any optional

    n object to which the this keyword can refer in the callback function. If thisArg is omitted, undefined is used.

Returns

Array<G>

An array containing the result of calling the callback function on each element in the list.

public map(callback: (value: T, index: number, array: T[]) => G, thisArg?: any): Array<G>

Calls the specified callback function on each element of a list, and returns an array that contains the results.

Parameters

  • callback: (value: T, index: number, array: T[]) => G

    A function that accepts up to three arguments. The function is called for each element in the list.

  • thisArg?: any optional

    n object to which the this keyword can refer in the callback function. If thisArg is omitted, undefined is used.

Returns

Array<G>

An array containing the result of calling the callback function on each element in the list.

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

Notifies listeners that a property value was updated.

Parameters

  • name: string

    The name of the property that is being updated.

  • newValue: any

    The new value for the property.

  • oldValue: any

    The old value for the property.

Returns

Promise

A promise that is completed when the notifications are complete.

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

Notifies listeners that a property value was updated.

Parameters

  • name: string

    The name of the property that is being updated.

  • newValue: any

    The new value for the property.

  • oldValue: any

    The old value for the property.

Returns

Promise

A promise that is completed when the notifications are complete.

public notifyReload()

Forces the list to send a reload notification to any listeners.

public notifyReload()

Forces the list to send a reload notification to any listeners.

public onitemchanged(eventInfo: CustomEvent)

An item in the list has changed its value.

Parameters

  • eventInfo: CustomEvent

    An object that contains information about the event. The detail contains the following information: index, key, newItem, newValue, oldItem, oldValue.

public onitemchanged(eventInfo: CustomEvent)

An item in the list has changed its value.

Parameters

  • eventInfo: CustomEvent

    An object that contains information about the event. The detail contains the following information: index, key, newItem, newValue, oldItem, oldValue.

public oniteminserted(eventInfo: CustomEvent)

A new item has been inserted into the list.

Parameters

  • eventInfo: CustomEvent

    An object that contains information about the event. The detail contains the following information: index, key, value.

public oniteminserted(eventInfo: CustomEvent)

A new item has been inserted into the list.

Parameters

  • eventInfo: CustomEvent

    An object that contains information about the event. The detail contains the following information: index, key, value.

public onitemmoved(eventInfo: CustomEvent)

An item has been changed locations in the list.

Parameters

  • eventInfo: CustomEvent

    An object that contains information about the event. The detail contains the following information: index, key, value.

public onitemmoved(eventInfo: CustomEvent)

An item has been changed locations in the list.

Parameters

  • eventInfo: CustomEvent

    An object that contains information about the event. The detail contains the following information: index, key, value.

public onitemmutated(eventInfo: CustomEvent)

An item has been mutated. This event occurs as a result of calling the notifyMutated method.

Parameters

  • eventInfo: CustomEvent

    An object that contains information about the event. The detail contains the following information: index, key, value.

public onitemmutated(eventInfo: CustomEvent)

An item has been mutated. This event occurs as a result of calling the notifyMutated method.

Parameters

  • eventInfo: CustomEvent

    An object that contains information about the event. The detail contains the following information: index, key, value.

public onitemremoved(eventInfo: CustomEvent)

An item has been removed from the list.

Parameters

  • eventInfo: CustomEvent

    An object that contains information about the event. The detail contains the following information: index, key, value.

public onitemremoved(eventInfo: CustomEvent)

An item has been removed from the list.

Parameters

  • eventInfo: CustomEvent

    An object that contains information about the event. The detail contains the following information: index, key, value.

public onreload(eventInfo: CustomEvent)

The list has been refreshed. Any references to items in the list may be incorrect.

Parameters

  • eventInfo: CustomEvent

    An object that contains information about the event. The detail property of this object is null.

public onreload(eventInfo: CustomEvent)

The list has been refreshed. Any references to items in the list may be incorrect.

Parameters

  • eventInfo: CustomEvent

    An object that contains information about the event. The detail property of this object is null.

public pop(): T in WinJS.Binding.ListBaseWithMutators<T>

Removes the last element from a list and returns it.

Returns

T in WinJS.Binding.ListBaseWithMutators<T>

The last element from the list.

public push(value: T in WinJS.Binding.ListBaseWithMutators<T>): number

Appends new element(s) to a list, and returns the new length of the list.

Parameters

  • value: T in WinJS.Binding.ListBaseWithMutators<T>

    The element to insert at the end of the list.

Returns

number

The new length of the list.

public reduce(callback: (previousValue: any, currentValue: any, currentIndex: number, array: T[]) => T, initiallValue?: T in WinJS.Binding.ListBase<T>): T in WinJS.Binding.ListBase<T>

Accumulates a single result by calling the specified callback function for all elements in a list. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function.

Parameters

  • callback: (previousValue: any, currentValue: any, currentIndex: number, array: T[]) => T

    A function that accepts up to four arguments. These arguments are: previousValue, currentValue, currentIndex, array. The function is called for each element in the list.

  • initiallValue?: T in WinJS.Binding.ListBase<T> optional

    If initialValue is specified, it is used as the value with which to start the accumulation. The first call to the function provides this value as an argument instead of a list value.

Returns

T in WinJS.Binding.ListBase<T>

The return value from the last call to the callback function.

public reduce(callback: (previousValue: any, currentValue: any, currentIndex: number, array: T[]) => T, initiallValue?: T in WinJS.Binding.ListBase<T>): T in WinJS.Binding.ListBase<T>

Accumulates a single result by calling the specified callback function for all elements in a list. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function.

Parameters

  • callback: (previousValue: any, currentValue: any, currentIndex: number, array: T[]) => T

    A function that accepts up to four arguments. These arguments are: previousValue, currentValue, currentIndex, array. The function is called for each element in the list.

  • initiallValue?: T in WinJS.Binding.ListBase<T> optional

    If initialValue is specified, it is used as the value with which to start the accumulation. The first call to the function provides this value as an argument instead of a list value.

Returns

T in WinJS.Binding.ListBase<T>

The return value from the last call to the callback function.

public reduceRight(callback: (previousValue: any, currentValue: any, currentIndex: number, array: T[]) => T, initialValue?: T in WinJS.Binding.ListBase<T>): T in WinJS.Binding.ListBase<T>

Accumulates a single result by calling the specified callback function for all elements in a list, starting with the last member of the list. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function.

Parameters

  • callback: (previousValue: any, currentValue: any, currentIndex: number, array: T[]) => T

    A function that accepts up to four arguments. These arguments are: previousValue, currentValue, currentIndex, array. The function is called for each element in the list.

  • initialValue?: T in WinJS.Binding.ListBase<T> optional

    If initialValue is specified, it is used as the value with which to start the accumulation. The first call to the callback function provides this value as an argument instead of a list value.

Returns

T in WinJS.Binding.ListBase<T>

The return value from the last call to callback function.

public reduceRight(callback: (previousValue: any, currentValue: any, currentIndex: number, array: T[]) => T, initialValue?: T in WinJS.Binding.ListBase<T>): T in WinJS.Binding.ListBase<T>

Accumulates a single result by calling the specified callback function for all elements in a list, starting with the last member of the list. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function.

Parameters

  • callback: (previousValue: any, currentValue: any, currentIndex: number, array: T[]) => T

    A function that accepts up to four arguments. These arguments are: previousValue, currentValue, currentIndex, array. The function is called for each element in the list.

  • initialValue?: T in WinJS.Binding.ListBase<T> optional

    If initialValue is specified, it is used as the value with which to start the accumulation. The first call to the callback function provides this value as an argument instead of a list value.

Returns

T in WinJS.Binding.ListBase<T>

The return value from the last call to callback function.

public removeEventListener(type: string, listener: Function, useCapture?: boolean)

Removes an event listener from the control.

Parameters

  • type: string

    The type (name) of the event.

  • listener: Function

    The listener to remove.

  • useCapture?: boolean optional

    true if capture is to be initiated, otherwise false.

public removeEventListener(type: string, listener: Function, useCapture?: boolean)

Removes an event listener from the control.

Parameters

  • type: string

    The type (name) of the event.

  • listener: Function

    The listener to remove.

  • useCapture?: boolean optional

    true if capture is to be initiated, otherwise false.

public shift(): T in WinJS.Binding.ListBaseWithMutators<T>

Removes the first element from a list and returns it.

Returns

T in WinJS.Binding.ListBaseWithMutators<T>

The first element from the list.

public slice(begin: number, end: number): Array<T>

Extracts a section of a list and returns a new list.

Parameters

  • begin: number

    The index that specifies the beginning of the section.

  • end: number

    The index that specifies the end of the section.

Returns

Array<T>

Returns a section of list.

public slice(begin: number, end: number): Array<T>

Extracts a section of a list and returns a new list.

Parameters

  • begin: number

    The index that specifies the beginning of the section.

  • end: number

    The index that specifies the end of the section.

Returns

Array<T>

Returns a section of list.

public some(callback: (value: T, index: number, array: T[]) => boolean, thisArg?: any): boolean

Checks whether the specified callback function returns true for any element of a list.

Parameters

  • callback: (value: T, index: number, array: T[]) => boolean

    A function that accepts up to three arguments. The function is called for each element in the list until it returns true, or until the end of the list.

  • thisArg?: any optional

    An object to which the this keyword can refer in the callback function. If thisArg is omitted, undefined is used.

Returns

boolean

true if callback returns true for any element in the list.

public some(callback: (value: T, index: number, array: T[]) => boolean, thisArg?: any): boolean

Checks whether the specified callback function returns true for any element of a list.

Parameters

  • callback: (value: T, index: number, array: T[]) => boolean

    A function that accepts up to three arguments. The function is called for each element in the list until it returns true, or until the end of the list.

  • thisArg?: any optional

    An object to which the this keyword can refer in the callback function. If thisArg is omitted, undefined is used.

Returns

boolean

true if callback returns true for any element in the list.

public unbind(name: string, action: Function): any

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

Parameters

  • name: string

    The name of the property to unbind. If this parameter is omitted, all listeners for all events are removed.

  • action: Function

    The function to remove from the listener list for the specified property. If this parameter is omitted, all listeners are removed for the specific property.

Returns

any

This object is returned.

public unbind(name: string, action: Function): any

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

Parameters

  • name: string

    The name of the property to unbind. If this parameter is omitted, all listeners for all events are removed.

  • action: Function

    The function to remove from the listener list for the specified property. If this parameter is omitted, all listeners are removed for the specific property.

Returns

any

This object is returned.

public unshift(value: T in WinJS.Binding.ListBaseWithMutators<T>): number

Appends new element(s) to a list, and returns the new length of the list.

Parameters

  • value: T in WinJS.Binding.ListBaseWithMutators<T>

    The element to insert at the start of the list.

Returns

number

The new length of the list.