How to use the ix.Iterable.empty function in ix

To help you get started, we’ve selected a few ix examples, based on popular ways it is used in public projects.

github marinels / webrx-react / src / Components / Common / DataGrid / DataGridViewModel.ts View on Github external
.catch(e => {
            this.alertForError(e, 'Data Response Error');

            return this.wx.getObservable<DataSourceResponse<T>>({
              items: Iterable.empty<T>(),
              count: 0,
            });
          });
      })
github marinels / webrx-react / src / Components / Common / DataGrid / DataGridViewModel.ts View on Github external
.merge(
        this.requests.changed
          .map(() => true),
        this.responses.changed
          .map(() => false),
      )
      .toProperty(true);

    const validResponses = this.wx
      .whenAny(this.responses, x => x)
      .filterNull()
      .share();

    this.projectedSource = validResponses
      .map(x => x.items)
      .toProperty(Iterable.empty<T>(), false);

    this.projectedCount = validResponses
      .map(x => x.count)
      .toProperty();

    if (this.pager != null) {
      this.addSubscription(
        this.wx
          .whenAny(
            this.projectedCount,
            x => x,
          )
          .filterNull()
          .invokeCommand(this.pager.updateCount),
      );
github marinels / webrx-react / src / Components / Common / Items / ItemsViewModel.ts View on Github external
import { Iterable } from 'ix';
import { Observable } from 'rxjs';

import { IterableLike, ObservableLike, ReadOnlyProperty, Command } from '../../../WebRx';
import { BaseViewModel } from '../../React';

export class ItemsViewModel<T> extends BaseViewModel {
  public static displayName = 'ItemsViewModel';

  protected readonly emptySource = Iterable.empty<T>();

  public readonly source: ReadOnlyProperty<IterableLike<T>>;
  public readonly count: ReadOnlyProperty<number>;

  constructor(
    source: ObservableLike<IterableLike<T>>,
  ) {
    super();

    this.source = this.wx
      .getObservableOrAlert(
        () => {
          return this.wx
            .getObservable(source)
            .map(x => Iterable.from(x));
        },
github marinels / webrx-react / src / Components / Common / ItemListPanel / TreeItemListPanelViewModel.ts View on Github external
export function filterTreeItems<T>(
  items: IterableLike<T> | undefined,
  itemsSource: (item: T) => (IterableLike<T> | undefined),
  itemsAssign: (item: T, items: Iterable<T>) => T,
  filter: (item: T) => boolean,
): Iterable<T> {
  if (items == null) {
    return Iterable.empty<T>();
  }

  return Iterable
    .from(items)
    .map(x => {
      const result = filterTreeItems(itemsSource(x), itemsSource, itemsAssign, filter);

      if (result.some(() => true) || filter(x)) {
        return itemsAssign(x, result);
      }

      return undefined;
    })
    .filterNull();
}
github marinels / webrx-react / src / Components / Common / ItemListPanel / AsyncTreeItemListPanelViewModel.ts View on Github external
constructor(
    protected readonly responseSelector: (request: DataSourceRequest<ItemListPanelContext<TRequestContext>> | undefined) => ObservableOrValue<DataSourceResponse<T> | undefined>,
    itemsSource: (item: T) => (IterableLike<T> | undefined),
    search?: SearchViewModel | null,
    context?: ObservableLike<TRequestContext>,
    rateLimit = AsyncDataGridViewModel.DefaultRateLimit,
  ) {
    super(Iterable.empty<T>(), itemsSource, x => x, undefined, search, context, rateLimit);
  }
github marinels / webrx-react / src / Components / Common / DataGrid / AsyncDataGridViewModel.ts View on Github external
constructor(
    protected readonly responseSelector: (request: DataSourceRequest<TRequestContext> | undefined) => ObservableOrValue<DataSourceResponse<T> | undefined>,
    pager?: PagerViewModel,
    context?: ObservableLike<TRequestContext>,
    rateLimit = AsyncDataGridViewModel.DefaultRateLimit,
  ) {
    super(Iterable.empty<T>(), pager, context, undefined, rateLimit);
  }