Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

  • Readonly<Record<string, string>>
    • EventCollection

Index

Events

ACTIVE_CHANGED: "active-change"

Fired when the currently active item changes.

example
import { users } from '../data/users';

const list = models.utils.withActive(models.collection());

list.on(Events.ACTIVE_CHANGED, (curr, prev) => {
console.log('active changed from', prev, 'to', curr);
});

list.add(1, 2, 3);
list.active(2); // "active changed from 1 to 2"
FILTER_CHANGED: "filter-change"

Fired when filterBy is invoked.

example
const list = models.utils.withFiltering(models.collection());
const isOdd = num => num % 2;

list.on(Events.FILTER_CHANGED, () => {
console.log('filter changed');
});

list.add(1, 2, 3);
list.filterBy(isOdd); // "filter changed"
GROUP_CHANGED: "group-change"

Fired when groupBy is invoked.

example
import { users } from '../data/users';

const list = models.utils.withGrouping(models.collection());

list.on(Events.GROUP_CHANGED, () => {
console.log('group changed');
});

list.add(...users);
list.groupBy(['region']); // "group changed"
ITEMS_UPDATED: "items-update"

Fired when one or more items in the collection were updated during an upsert or merge operation.

example
import { newUsers, allUsers, activeUsers } from '../data/users';

const list = models.utils.withUpdating(models.collection(), 'username');

list.on(Events.ITEMS_UPDATED, (modified) => {
console.log('users updated', modified);
});

list.add(...newUsers);
list.upsert(...allUsers);
list.merge(...activeUsers);
ORDER_CHANGED: "order-change"

Fired when orderBy is invoked.

example
const list = models.utils.withOrdering(models.collection());

list.on(Events.ORDER_CHANGED, () => {
console.log('order changed');
});

list.add(1, 2, 3);
list.orderBy([], ['desc']); // "order changed"
PAGE_CHANGED: "page-change"

Fired when the current page has changed.

example
import { users } from '../data/users';

const list = models.utils.withPaging(models.collection(), 2);

list.on(Events.PAGE_CHANGED, (pageIndex) => {
console.log('page changed', pageIndex);
});

list.add(...users);
list.nextPage(); // "page changed 1"
list.prevPage(); // "page changed 0"
SELECTION_CHANGED: "selection-change"

Fired when the selected items have changed.

example
import { users } from '../data/users';

const list = models.utils.withSelection(models.collection());

list.on(Events.SELECTION_CHANGED, (selected) => {
console.log('selection changed', selected);
});

list.add(1, 2, 3);
list.selected(); // []
list.selected(2, 3); // "selection changed [2, 3]"
UNIQUE_CHANGED: "unique-change"

Fired when a new uniqueness method is specified.

example
const list = models.utils.withUnique(models.collection(1.0, 1.5, 2.0));

list.on(Events.UNIQUE_CHANGED, () => {
console.log('items:', list.items());
});

list.uniqueBy(Math.floor); // "items: [1.0, 2.0]"