Options
All
  • Public
  • Public/Protected
  • All
Menu

Module main

Index

Type Aliases

AnyFunc: ((...args: any[]) => any)

Type declaration

    • (...args: any[]): any
    • Parameters

      • Rest ...args: any[]

      Returns any

Atom<T>: GetFn<T> & { error: any; get: GetFn<T>; key: string | undefined; loading: boolean; state: T; task: Promise<T> | undefined; abort: any; on: any; reset: any; snapshot: any }

Type Parameters

  • T = any

AtomErrorEvent: { error: any; rollback: any }

Type declaration

AtomExtraProps<THelpers>: { [ key in keyof THelpers]: THelpers[key] extends ((context: any, ...args: infer A) => infer R) ? ((...args: A) => R) : never }

Type Parameters

  • THelpers = {}

AtomFamily<A, T>: { clear: any; delete: any; forEach: any; get: any; has: any } & (T extends UpdatableAtom<infer V> ? { set: SetFn<V> } : {})

Type Parameters

  • A extends any[]

  • T

AtomHelpers<T>: {}

Type Parameters

  • T

Type declaration

  • [key: string]: ((context: T, ...args: any[]) => any)
      • (context: T, ...args: any[]): any
      • Parameters

        • context: T
        • Rest ...args: any[]

        Returns any

AtomOptions: { key?: string; onChange?: VoidFunction; onLoading?: VoidFunction; load?: any; onError?: any; save?: any }

Type declaration

  • Optional key?: string

    name of atom, for debugging purpose

  • Optional onChange?: VoidFunction
  • Optional onLoading?: VoidFunction
  • load?:function
    • load(): undefined | { state: any }
  • onError?:function
    • onError(error: any): void
  • save?:function
    • save(state: any): void
Awaiter<T>: { $$type: "awaiter"; promise: Promise<T> }

Type Parameters

  • T

Type declaration

  • $$type: "awaiter"
  • promise: Promise<T>
CompareFn<T>: ((a: T, b: T) => boolean)

Type Parameters

  • T = any

Type declaration

    • (a: T, b: T): boolean
    • Parameters

      • a: T
      • b: T

      Returns boolean

ComputedAtom<T>: UpdatableAtom<T>

Type Parameters

  • T

Context: { aborted: boolean; signal: AbortController["signal"] | undefined; abort: any }

Type declaration

  • Readonly aborted: boolean

    is aborted

  • Readonly signal: AbortController["signal"] | undefined

    AbortController signal

  • abort:function
    • abort(): void
CreateAtom: { (): UpdatableAtom<void>; <T>(computeFn: ((context: Context) => T | Awaiter<T>), options?: AtomOptions): ComputedAtom<T>; <T, H>(computeFn: ((context: Context) => T | Awaiter<T>), options: AtomOptions & { helpers: H }): GetFn<T> & Omit<Atom<T>, "state"> & { set: SetFn<T>; state: T; cancel: any; defer: any; mutate: any } & AtomExtraProps<H>; <T>(initialState: T | Promise<T>, options?: AtomOptions): UpdatableAtom<T>; <T, H>(initialState: T | Promise<T>, options: AtomOptions & { helpers: H }): GetFn<T> & Omit<Atom<T>, "state"> & { set: SetFn<T>; state: T; cancel: any; defer: any; mutate: any } & AtomExtraProps<H>; <T, A>(initialState: T, reducer: ((state: NoInfer<T>, action: A, context: Context) => T | Awaiter<T>), options?: EmittableOptions<A>): EmittableAtom<T, A>; <T, H, A>(initialState: T, reducer: ((state: NoInfer<T>, action: A, context: Context) => T | Awaiter<T>), options: AtomOptions & { initAction?: A; onEmit?: any } & { helpers: H }): GetFn<T> & { error: any; get: GetFn<T>; key: string | undefined; loading: boolean; state: T; task: Promise<T> | undefined; abort: any; on: any; reset: any; snapshot: any } & { emit: EmitFn<T, A>; cancel: any; on: any } & AtomExtraProps<H> }

Type declaration

CreateSnapshot: { (atoms: Atom<any>[], reset?: boolean): VoidFunction; <T>(atoms: Atom<any>[], callback: (() => T)): T; <T>(atoms: Atom<any>[], reset: boolean, callback: (() => T)): T }

Type declaration

    • (atoms: Atom<any>[], reset?: boolean): VoidFunction
    • <T>(atoms: Atom<any>[], callback: (() => T)): T
    • <T>(atoms: Atom<any>[], reset: boolean, callback: (() => T)): T
    • Parameters

      • atoms: Atom<any>[]
      • Optional reset: boolean

      Returns VoidFunction

    • Type Parameters

      • T

      Parameters

      • atoms: Atom<any>[]
      • callback: (() => T)
          • (): T
          • Returns T

      Returns T

    • Type Parameters

      • T

      Parameters

      • atoms: Atom<any>[]
      • reset: boolean
      • callback: (() => T)
          • (): T
          • Returns T

      Returns T

EmitFn<T, A>: ((action: A) => EmittableAtom<T, A>)

Type Parameters

  • T

  • A

Type declaration

    • emit an action and atom reducer will handle the action

      Parameters

      • action: A

      Returns EmittableAtom<T, A>

EmittableAtom<T, A>: Atom<T> & { emit: EmitFn<T, A>; cancel: any; on: any }

Type Parameters

  • T = any

  • A = void

EmittableOptions<A>: AtomOptions & { initAction?: A; onEmit?: any }

Type Parameters

  • A = any

GetFn<T>: { (): T; <R>(selector: ((state: T) => R)): R; <K>(path: K): PathValue<T, K> }

Type Parameters

  • T

Type declaration

    • (): T
    • <R>(selector: ((state: T) => R)): R
    • <K>(path: K): PathValue<T, K>
    • get current state of the atom

      Returns T

    • get result of the selector, the selector retrieves current state of the atom

      Type Parameters

      • R

      Parameters

      • selector: ((state: T) => R)
          • (state: T): R
          • Parameters

            • state: T

            Returns R

      Returns R

    • Type Parameters

      • K extends string

      Parameters

      • path: K

      Returns PathValue<T, K>

KeyOf: { <T, E>(obj: T, exclude: E[]): Exclude<keyof T, E>[]; <T>(obj: T): (keyof T)[] }

Type declaration

    • <T, E>(obj: T, exclude: E[]): Exclude<keyof T, E>[]
    • <T>(obj: T): (keyof T)[]
    • Type Parameters

      • T

      • E extends string | number | symbol

      Parameters

      • obj: T
      • exclude: E[]

      Returns Exclude<keyof T, E>[]

    • Type Parameters

      • T

      Parameters

      • obj: T

      Returns (keyof T)[]

Listener<T, A>: ((e: T, a: A) => void)

Type Parameters

  • T

  • A = void

Type declaration

    • (e: T, a: A): void
    • Parameters

      • e: T
      • a: A

      Returns void

Mutation<T, R>: ((prev: T) => R)

Type Parameters

  • T

  • R = T

Type declaration

    • (prev: T): R
    • Parameters

      • prev: T

      Returns R

NoInfer<T>: [T][T extends any ? 0 : never]

Type Parameters

  • T

Nullable<T>: T | undefined | null

Type Parameters

  • T

Rearg: { (func: Function, indexes: number[]): ((...args: any[]) => any); (func: Function, skip: number): ((...args: any[]) => any) }

Type declaration

    • (func: Function, indexes: number[]): ((...args: any[]) => any)
    • (func: Function, skip: number): ((...args: any[]) => any)
    • Creates a function that invokes func with arguments arranged according to the specified indexes where the argument value at the first index is provided as the first argument, the argument value at the second index is provided as the second argument, and so on.

      Parameters

      • func: Function
      • indexes: number[]

      Returns ((...args: any[]) => any)

        • (...args: any[]): any
        • Creates a function that invokes func with arguments arranged according to the specified indexes where the argument value at the first index is provided as the first argument, the argument value at the second index is provided as the second argument, and so on.

          Parameters

          • Rest ...args: any[]

          Returns any

    • Creates a function that invokes func with arguments that are selected from input arguments after skipped N arguments.

      Parameters

      • func: Function
      • skip: number

      Returns ((...args: any[]) => any)

        • (...args: any[]): any
        • Creates a function that invokes func with arguments that are selected from input arguments after skipped N arguments.

          Parameters

          • Rest ...args: any[]

          Returns any

SetFn<T>: { (mutation: Mutation<T, T>, ...mutations: Mutation<T, T>[]): VoidFunction; (state: T | ((prev: T, context: Context) => T | Promise<T> | Awaiter<T>) | Promise<T> | Awaiter<T>): VoidFunction }

Type Parameters

  • T

Type declaration

    • (mutation: Mutation<T, T>, ...mutations: Mutation<T, T>[]): VoidFunction
    • (state: T | ((prev: T, context: Context) => T | Promise<T> | Awaiter<T>) | Promise<T> | Awaiter<T>): VoidFunction
    • update current state of the atom by using specfied mutations

      Parameters

      Returns VoidFunction

    • update current state of the atom

      Parameters

      Returns VoidFunction

Task<T, A>: { aborted: boolean; abort: any; runner: any }

Type Parameters

  • T

  • A extends any[]

Type declaration

UpdatableAtom<T>: GetFn<T> & Omit<Atom<T>, "state"> & { set: SetFn<T>; state: T; cancel: any; defer: any; mutate: any }

Type Parameters

  • T = any

Wait: { <A>(awaitable: Atom<A> | Awaitable<A> | Promise<A>): Awaiter<A>; <A, T, P>(awaitable: Atom<A> | Awaitable<A> | Promise<A>, fn: ((value: A, ...args: P) => T | Awaiter<T>), ...args: P): T extends Promise<any> ? never : Awaiter<T>; <A, T, P>(awaitables: A, fn: ((values: { [ key in string | number | symbol]: A[key] extends Atom<V> ? V : A[key] extends Promise<V> ? V : never }, ...args: P) => T | Awaiter<T>), ...args: P): T extends Promise<any> ? never : Awaiter<T> }

Type declaration

    • <A>(awaitable: Atom<A> | Awaitable<A> | Promise<A>): Awaiter<A>
    • <A, T, P>(awaitable: Atom<A> | Awaitable<A> | Promise<A>, fn: ((value: A, ...args: P) => T | Awaiter<T>), ...args: P): T extends Promise<any> ? never : Awaiter<T>
    • <A, T, P>(awaitables: A, fn: ((values: { [ key in string | number | symbol]: A[key] extends Atom<V> ? V : A[key] extends Promise<V> ? V : never }, ...args: P) => T | Awaiter<T>), ...args: P): T extends Promise<any> ? never : Awaiter<T>
    • Type Parameters

      • A

      Parameters

      Returns Awaiter<A>

    • Type Parameters

      • A

      • T

      • P extends any[]

      Parameters

      • awaitable: Atom<A> | Awaitable<A> | Promise<A>
      • fn: ((value: A, ...args: P) => T | Awaiter<T>)
          • (value: A, ...args: P): T | Awaiter<T>
          • Parameters

            • value: A
            • Rest ...args: P

            Returns T | Awaiter<T>

      • Rest ...args: P

      Returns T extends Promise<any> ? never : Awaiter<T>

    • Type Parameters

      • A extends {}

      • T

      • P extends any[]

      Parameters

      • awaitables: A
      • fn: ((values: { [ key in string | number | symbol]: A[key] extends Atom<V> ? V : A[key] extends Promise<V> ? V : never }, ...args: P) => T | Awaiter<T>)
          • (values: { [ key in string | number | symbol]: A[key] extends Atom<V> ? V : A[key] extends Promise<V> ? V : never }, ...args: P): T | Awaiter<T>
          • Parameters

            • values: { [ key in string | number | symbol]: A[key] extends Atom<V> ? V : A[key] extends Promise<V> ? V : never }
            • Rest ...args: P

            Returns T | Awaiter<T>

      • Rest ...args: P

      Returns T extends Promise<any> ? never : Awaiter<T>

Watch: { <T>(changeSelector: (() => T), callback: ((value: T) => void)): VoidFunction; <T>(changeSelector: (() => T), options: WatchOptions<T>): VoidFunction }

Type declaration

    • <T>(changeSelector: (() => T), callback: ((value: T) => void)): VoidFunction
    • <T>(changeSelector: (() => T), options: WatchOptions<T>): VoidFunction
    • Type Parameters

      • T

      Parameters

      • changeSelector: (() => T)
          • (): T
          • Returns T

      • callback: ((value: T) => void)
          • (value: T): void
          • Parameters

            • value: T

            Returns void

      Returns VoidFunction

    • Type Parameters

      • T

      Parameters

      • changeSelector: (() => T)
          • (): T
          • Returns T

      • options: WatchOptions<T>

      Returns VoidFunction

WatchOptions<T>: { defer?: boolean; callback?: any; compare?: any }

Type Parameters

  • T

Type declaration

Functions

  • delay<T>(ms?: number, value?: T): Promise<T> & { cancel: any }
  • family<A, T>(createFn: ((...args: A) => T)): AtomFamily<A, T>
  • isAtom<T>(value: any): value is Atom<T>
  • keyOf<T, E>(obj: T, exclude: E[]): Exclude<keyof T, E>[]
  • keyOf<T>(obj: T): (keyof T)[]
  • rearg(func: Function, indexes: number[]): ((...args: any[]) => any)
  • rearg(func: Function, skip: number): ((...args: any[]) => any)
  • Parameters

    • func: Function
    • indexes: number[]

    Returns ((...args: any[]) => any)

      • (...args: any[]): any
      • Creates a function that invokes func with arguments arranged according to the specified indexes where the argument value at the first index is provided as the first argument, the argument value at the second index is provided as the second argument, and so on.

        Parameters

        • Rest ...args: any[]

        Returns any

  • Parameters

    • func: Function
    • skip: number

    Returns ((...args: any[]) => any)

      • (...args: any[]): any
      • Creates a function that invokes func with arguments that are selected from input arguments after skipped N arguments.

        Parameters

        • Rest ...args: any[]

        Returns any

  • snapshot(atoms: Atom<any>[], reset?: boolean): VoidFunction
  • snapshot<T>(atoms: Atom<any>[], callback: (() => T)): T
  • snapshot<T>(atoms: Atom<any>[], reset: boolean, callback: (() => T)): T
  • throws(error: string | Error): never
  • wait<A>(awaitable: Atom<A> | Awaitable<A> | Promise<A>): Awaiter<A>
  • wait<A, T, P>(awaitable: Atom<A> | Awaitable<A> | Promise<A>, fn: ((value: A, ...args: P) => T | Awaiter<T>), ...args: P): T extends Promise<any> ? never : Awaiter<T>
  • wait<A, T, P>(awaitables: A, fn: ((values: { [ key in string | number | symbol]: A[key] extends Atom<V> ? V : A[key] extends Promise<V> ? V : never }, ...args: P) => T | Awaiter<T>), ...args: P): T extends Promise<any> ? never : Awaiter<T>
  • Type Parameters

    • A

    Parameters

    Returns Awaiter<A>

  • Type Parameters

    • A

    • T

    • P extends any[]

    Parameters

    • awaitable: Atom<A> | Awaitable<A> | Promise<A>
    • fn: ((value: A, ...args: P) => T | Awaiter<T>)
        • (value: A, ...args: P): T | Awaiter<T>
        • Parameters

          • value: A
          • Rest ...args: P

          Returns T | Awaiter<T>

    • Rest ...args: P

    Returns T extends Promise<any> ? never : Awaiter<T>

  • Type Parameters

    • A extends {}

    • T

    • P extends any[]

    Parameters

    • awaitables: A
    • fn: ((values: { [ key in string | number | symbol]: A[key] extends Atom<V> ? V : A[key] extends Promise<V> ? V : never }, ...args: P) => T | Awaiter<T>)
        • (values: { [ key in string | number | symbol]: A[key] extends Atom<V> ? V : A[key] extends Promise<V> ? V : never }, ...args: P): T | Awaiter<T>
        • Parameters

          • values: { [ key in string | number | symbol]: A[key] extends Atom<V> ? V : A[key] extends Promise<V> ? V : never }
          • Rest ...args: P

          Returns T | Awaiter<T>

    • Rest ...args: P

    Returns T extends Promise<any> ? never : Awaiter<T>

  • watch<T>(changeSelector: (() => T), callback: ((value: T) => void)): VoidFunction
  • watch<T>(changeSelector: (() => T), options: WatchOptions<T>): VoidFunction

Generated using TypeDoc