@mantlebee/ts-data
    Preparing search index...

    Class FilterExtension<TItem>

    Keeps a flat list of filters and sends it in the payload as a FiltersList, only when there is at least one filter. Write its key before the one of the PaginationExtension, so the count receives the filters.

    const filtering = new FilterExtension<User>();
    const dataSource = createDataSource(readUsers, { filtering });
    // Reads once the user stops typing, whatever the number of changes.
    filtering.on("filtersChange", () => dataSource.read());
    filtering.addFilter({ field: "name", operator: FilterOperators.contains, value: "ann" });
    filtering.addFilter({ field: "age", operator: FilterOperators.greaterThanOrEqual, value: 18 });
    // payload.filters: { filters: [name contains "ann", age >= 18], logic: "and" }

    Type Parameters

    • TItem = Any

      Type of the items.

    Hierarchy (View Summary)

    Implements

    Index
    _changeDelay: number
    _eventBus: EventBus<FilterExtensionEvents<TItem>>

    Bus used to register handlers and to raise the events.

    _filters: List<Filter<TItem>> = []
    _logic: FilterLogics = FilterLogics.and
    • Registers a handler for an event.

      Type Parameters

      • TKey extends string

        Name of the event to listen to.

      Parameters

      Returns IDisposable

      a subscription; dispose it to remove this single handler.