mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
add doc describing ItemStore.sortItems (#2257)
* add doc describing ItemStore.sortItems Signed-off-by: Sebastian Malton <sebastian@malton.name> * fix wording Signed-off-by: Sebastian Malton <sebastian@malton.name> * fix spelling Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
parent
f543fc3ba1
commit
21585d882d
@ -40,9 +40,18 @@ export abstract class ItemStore<T extends ItemObject = ItemObject> {
|
|||||||
return this.items.findIndex(item => item.getId() === id);
|
return this.items.findIndex(item => item.getId() === id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return `items` sorted by the given ordering functions. If two elements of
|
||||||
|
* `items` are sorted to the same "index" then the next sorting function is used
|
||||||
|
* to determine where to place them relative to each other. Once the `sorting`
|
||||||
|
* functions have been all exhausted then the order is unchanged (ie a stable sort).
|
||||||
|
* @param items the items to be sorted (default: the current items in this store)
|
||||||
|
* @param sorting list of functions to determine sort order (default: sorting by name)
|
||||||
|
* @param order whether to sort from least to greatest (`"asc"` (default)) or vice-versa (`"desc"`)
|
||||||
|
*/
|
||||||
@action
|
@action
|
||||||
protected sortItems(items: T[] = this.items, sorting?: ((item: T) => any)[], order?: "asc" | "desc"): T[] {
|
protected sortItems(items: T[] = this.items, sorting: ((item: T) => any)[] = [this.defaultSorting], order?: "asc" | "desc"): T[] {
|
||||||
return orderBy(items, sorting || this.defaultSorting, order);
|
return orderBy(items, sorting, order);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected async createItem(...args: any[]): Promise<any>;
|
protected async createItem(...args: any[]): Promise<any>;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user