UNPKG

mobx-utils

Version:

Utility functions and common patterns for MobX

17 lines (16 loc) 568 B
import { IObservableArray } from "mobx"; /** * Moves an item from one position to another, checking that the indexes given are within bounds. * * @example * const source = observable([1, 2, 3]) * moveItem(source, 0, 1) * console.log(source.map(x => x)) // [2, 1, 3] * * @export * @param {ObservableArray<T>} target * @param {number} fromIndex * @param {number} toIndex * @returns {ObservableArray<T>} */ export declare function moveItem<T>(target: IObservableArray<T>, fromIndex: number, toIndex: number): IObservableArray<T> | undefined;