rx-datatable API
    Preparing search index...

    Interface ReactivityAdapter

    The list/tree/table components in this package re-render in response to state changes: changes to the selection, to the set of expanded parents, to the sort order, and (in apps built on an observability library) changes to the row data itself. Rather than depend on a particular state-management library, the components route all such behavior through a ReactivityAdapter.

    The default adapter (plainReactivityAdapter) has no dependencies: components re-render via ordinary React state updates, and collections created by observableSet/ observableArray are WatchableSet/WatchableArray instances that notify the components using them. What the default adapter cannot do is detect mutations of plain Sets/arrays you pass as props, or mutations of row data; pass new object/collection instances (or WatchableSet/WatchableArray) when changing them from outside, as is normal in React.

    If your app uses MobX, call setReactivityAdapter(mobxReactivityAdapter) (see the rx-datatable/mobx entry point) once at startup, before rendering. Then all components behave as observers: rows re-render when observable row data mutates, and you can pass observable.set/observable.array for selection/expansion/sort state.

    Each adapter member is named after the MobX API it abstracts.

    interface ReactivityAdapter {
        computed<T>(f: () => T): { get(): T };
        observableArray<T>(): WatchableArrayLike<T>;
        observableSet<K>(): ISet<K>;
        observer<C extends ComponentType<any>>(component: C): C;
        runInAction(f: () => void): void;
    }
    Index
    • Creates a lazily-(re)computed derived value (mobx computed). The default adapter does not cache: get() simply calls f(), which is correct but repeats the computation once per render.

      Type Parameters

      • T

      Parameters

      • f: () => T

      Returns { get(): T }

    • Creates the Set used for default selection/expandedParents state when the caller doesn't provide one (mobx observable.set). Default: a WatchableSet.

      Type Parameters

      • K

      Returns ISet<K>

    • Wraps a component so that it re-renders when observable values read during its last render change (mobx-react observer). Default: returns the component unchanged.

      Type Parameters

      • C extends ComponentType<any>

      Parameters

      • component: C

      Returns C

    • Runs a group of state mutations as a single atomic action, so observers see one change notification rather than several (mobx runInAction). Default: f().

      Parameters

      • f: () => void

      Returns void