Options
All
  • Public
  • Public/Protected
  • All
Menu

Module function/memoize/one

Index

References

Functions

References

Renames and re-exports one

Functions

  • one<T>(fn: T, isEqual?: (a: any, b: any) => boolean): T
  • Memoize function with multiply arguments of any type. Use it when you need to cache lookup only for last result (like reselect).

    example
    const addFlag = obj => ({...obj, flag: true });
    const memoize = memoizeOnce(addFlag));
    memoize(1); // from addFlag call
    memoize(1); // from cache
    memoize(1,2) // from addFlag call,
    memoize(1) // from addFlag call, cache was flashed on previous step

    Type parameters

    • T: Function

    Parameters

    • fn: T
    • isEqual: (a: any, b: any) => boolean = equal

      checks equality for two values

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

          • a: any
          • b: any

          Returns boolean

    Returns T

Generated using TypeDoc