Mixin: module:delite/Store

module:delite/Store

Mixin for store management that creates render items from store items after querying the store. The receiving class must extend decor/Evented or delite/Widget.

Classes extending this mixin automatically create render items that are consumable from store items after querying the store. This happens each time the store, query or queryOptions properties are set. If that store is Trackable it will be observed and render items will be automatically updated, added or deleted based on store notifications.

Source:
Show inherited

Members

query :Object

A query filter to apply to the store.

Type:
  • Object
Default Value:
  • {}
Source:

renderItems :Array.<Object>

The render items corresponding to the store items for this widget. This is filled from the store and is not supposed to be modified directly. Initially null.

Type:
  • Array.<Object>
Default Value:
  • null
Source:

store :dstore/Store

The store that contains the items to display.

Type:
  • dstore/Store
Default Value:
  • null
Source:

Methods

<protected> _itemRemoved(event)

When the store is observed and an item is removed in the store this method is called to remove the corresponding render item. This can be redefined but must not be called directly.

Parameters:
Name Type Description
event Event

The "remove" dstore/Trackable event.

Source:

<protected> computeProperties(props)

If the store parameters are invalidated, queries the store, creates the render items and calls initItems() when ready. If an error occurs a 'query-error' event will be fired.

Parameters:
Name Type Description
props
Source:

<protected> fetch(collection)

Called to perform the fetch operation on the collection.

Parameters:
Name Type Description
collection dstore/Collection

Items to be displayed.

Source:

<protected> initItems(renderItems) → {Array.<Object>}

This method is called once the query has been executed to initialize the renderItems array with the list of initial render items.

This method sets the renderItems property to the render items array passed as parameter. Once done, it fires a 'query-success' event.

Parameters:
Name Type Description
renderItems Array.<Object>

The array of initial render items to be set in the renderItems property.

Source:
Returns:

the renderItems array.

Type
Array.<Object>

<protected> itemAdded(index, renderItem, renderItems)

This method is called when an item is added in an observable store. The default implementation actually adds the renderItem to the renderItems array. This can be redefined but must not be called directly.

Parameters:
Name Type Description
index number

The index where to add the render item.

renderItem Object

The render item to be added.

renderItems Array.<Object>

The array of render items to add the render item to.

Source:

<protected> itemMoved(previousIndex, newIndex, renderItem, renderItems)

This method is called when an item is moved in an observable store. The default implementation actually moves the renderItem in the renderItems array. This can be redefined but must not be called directly.

Parameters:
Name Type Description
previousIndex number

The previous index of the render item.

newIndex number

The new index of the render item.

renderItem Object

The render item to be moved.

renderItems Array.<Object>

The array of render items to render item to be moved is part of.

Source:

<protected> itemRemoved(index, renderItems)

This method is called when an item is removed from an observable store. The default implementation actually removes a renderItem from the renderItems array. This can be redefined but must not be called directly.

Parameters:
Name Type Description
index number

The index of the render item to remove.

renderItems Array.<Object>

The array of render items to remove the render item from.

Source:

<protected> itemToRenderItem(item) → {Object}

Returns the widget internal item for a given store item. By default it returns the store item itself.

Parameters:
Name Type Description
item Object

The store item.

Source:
Returns:
Type
Object

<protected> itemUpdated(index, renderItem, renderItems)

This method is called when an item is updated in an observable store. The default implementation actually updates the renderItem in the renderItems array. This can be redefined but must not be called directly.

Parameters:
Name Type Description
index number

The index of the render item to update.

renderItem Object

The render item data the render item must be updated with.

renderItems Array.<Object>

The array of render items to render item to be updated is part of.

Source:

<protected> processCollection(collection)

Called to process the items returned after querying the store.

Parameters:
Name Type Description
collection dstore/Collection

Items to be displayed.

Source:

processQueryResult()

A function that processes the collection returned by the store query and returns a new collection (to sort it, etc...). This processing is applied before potentially tracking the store for modifications (if Trackable). Changing this function on the instance will not automatically refresh the class.

Default Value:
  • identity function
Source:

<protected> queryStoreAndInitItems(processQueryResult) → {Promise}

Queries the store, creates the render items and calls initItems() when ready. If an error occurs a 'query-error' event will be fired.

This method is not supposed to be called by application developer. It will be called automatically when modifying the store related properties or by the subclass if needed.

Parameters:
Name Type Description
processQueryResult

A function that processes the collection returned by the store query and returns a new collection (to sort it, etc...)., applied before tracking.

Source:
Returns:

If store to be processed is not null a promise that will be resolved when the loading process will be finished.

Type
Promise

renderItemToItem(renderItem) → {Object}

Creates a store item based from the widget internal item.

Parameters:
Name Type Description
renderItem Object

The render item.

Source:
Returns:
Type
Object