mobx-async-intercept

Use mobx intercepts with promises/async

Usage no npm install needed!

<script type="module">
  import mobxAsyncIntercept from 'https://cdn.skypack.dev/mobx-async-intercept';
</script>

README

TODO: Write an actual README

Caveat

Any new values intercepted will discard previous promises

type ArrayHandlerType<T> = IArrayWillChange<T>|IArrayWillSplice<T>;

export function interceptAsync<T>(
    target: IObservableValue<T>,
    change: (change: IValueWillChange<T>) => Promise<IValueWillChange<T>>
): Lambda;

export function interceptAsync<T>(
    target: IObservableArray<T>,
    change: (change: ArrayHandlerType<T>) => Promise<ArrayHandlerType<T>>
): Lambda;

export function interceptAsync<K, V>(
    target: ObservableMap<K, V>,
    change: (change: IMapWillChange<K, V>) => Promise<IMapWillChange<K, V>>
): Lambda;

export function interceptAsync(
    target: Object,
    change: (change: IObjectWillChange) => Promise<IObjectWillChange>
): Lambda;

export function interceptAsync<T extends Object, K extends keyof T>(
    target: T,
    property: K,
    change: (change: IValueWillChange<T[K]>) => Promise<IValueWillChange<T[K]>>
): Lambda;