Options
All
  • Public
  • Public/Protected
  • All
Menu

usestable

Index

Type Aliases

AnyComponent<P>: Component<P> | FC<P>

Type Parameters

  • P

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

CompareOption<T>: "strict" | "shallow" | "deep" | CompareFn<T>

Type Parameters

  • T = any

ComponentProps<C>: C extends ((props: infer TProps) => any) ? TProps : C extends FC<infer TProps> ? TProps : C extends Component<infer TProps> ? TProps : never

Type Parameters

  • C

Stable<T>: { [ key in keyof Omit<T, "$extra">]: T[key] } & (T extends { $extra: infer TExtra } ? TExtra extends Record<string, any> ? { [ key in keyof TExtra]: TExtra[key] extends ((...args: infer TArgs) => any) ? ((...args: TArgs) => TExtra["dispatch"] extends (() => infer TResult) ? TResult : any) : never } : {} : {})

Type Parameters

  • T extends Record<string, any>

StableProps<T>: "*" | (keyof T)[] | { [ name in keyof T]: true | CompareOption<T[name]> }

Type Parameters

  • T = any

Variables

useStable: UseStable = ...

create stable object / factory

param args
returns

Functions

  • deepEqual(a: any, b: any): boolean
  • defaultEqual(a: any, b: any, objectCompare?: CompareFn<any>): boolean
  • perform comparison for 2 values. This compare function also handle Date and Regex comparisons the date values are equal if their timestamps (a value return from getTime() method) are equal the regex values are equal if their string values (a value return from toString() method) are equal objectCompare will be called if both values are objects

    Parameters

    • a: any
    • b: any
    • Optional objectCompare: CompareFn<any>

    Returns boolean

  • isPromiseLike(value: any): value is Promise<any>
  • shallowEqual(a: any, b: any, valueCompare?: CompareFn<any>): boolean
  • perfrom shallow compare for 2 values. by default, shallowCompare uses defaultCompare to compare array items, object prop values

    Parameters

    • a: any
    • b: any
    • valueCompare: CompareFn<any> = defaultEqual

    Returns boolean

  • stable<C, P>(component: C, options?: Options<P>): FC<P>
  • useInit<T>(callback: (() => T)): T
  • withExtra<TProps, TResult>(props: TProps, invoker: ((payload: any) => TResult)): (<TName>(name: TName, ...args: TProps[TName] extends ((...args: TArgs) => any) ? TArgs : []) => TResult)
  • Type Parameters

    • TProps extends Record<string, any>

    • TResult = any

    Parameters

    • props: TProps
    • invoker: ((payload: any) => TResult)
        • (payload: any): TResult
        • Parameters

          • payload: any

          Returns TResult

    Returns (<TName>(name: TName, ...args: TProps[TName] extends ((...args: TArgs) => any) ? TArgs : []) => TResult)

      • <TName>(name: TName, ...args: TProps[TName] extends ((...args: TArgs) => any) ? TArgs : []): TResult
      • Type Parameters

        • TName extends string | number | symbol

        Parameters

        • name: TName
        • Rest ...args: TProps[TName] extends ((...args: TArgs) => any) ? TArgs : []

        Returns TResult

Generated using TypeDoc