Options
All
  • Public
  • Public/Protected
  • All
Menu

Class HookCallFactory<H, R>

Type parameters

Hierarchy

  • HookCallFactory

Index

Constructors

constructor

  • Parameters

    • hook: H
    • Optional defaultValue: R

    Returns HookCallFactory

Properties

call

call: Mod[H]

Methods

setDefault

  • setDefault(defaultValue: R): this
  • Sets the default value to return (if no hooks provide a value).

    Parameters

    • defaultValue: R

    Returns this

setExpectedResult

  • setExpectedResult(result: number): this
  • setExpectedResult(resultPredicate: (result: R) => boolean): this
  • Sets the expected result type.

    Parameters

    • result: number

      A result type using the TypeFlag flags.

      Example usage:

      setExpectedResult(TypeFlag.Undefined | TypeFlag.Number)

    Returns this

  • Sets the expected result to have to match a predicate

    Parameters

    • resultPredicate: (result: R) => boolean

      A predicate with which to match the result.

      Example usage:

      setExpectedResult((result) => result instanceof BaseHumanEntity)
        • (result: R): boolean
        • Parameters

          • result: R

          Returns boolean

    Returns this

setReduceStrategy

  • setReduceStrategy(reduceStrategy: IReduceStrategy<R>): this
  • setReduceStrategy(reduceStrategy: IReduceStrategy<R>, shouldPassCurrentResultToMods?: undefined | false | true): this
  • Sets the "reduce" strategy for this hook call. By default, the strategy is ReduceStrategy.Last, wherein all mod hooks are called and the last valid result is returned.

    Parameters

    • reduceStrategy: IReduceStrategy<R>

      A reduce strategy. You can either use a built-in ReduceStategy or provide your own reducer method.

    Returns this

  • Sets the "reduce" strategy for this hook call. By default, the strategy is ReduceStrategy.Last, wherein all mod hooks are called and the last valid result is returned.

    Parameters

    • reduceStrategy: IReduceStrategy<R>

      A reduce strategy. You can either use a built-in ReduceStategy or provide your own reducer method.

    • Optional shouldPassCurrentResultToMods: undefined | false | true

      Whether the current result value should be passed as the first argument to the hook methods. Each valid hook result can update the current result value, which will change the argument for the next hook method.

      Note: Passing the current result to mods replaces the first argument passed to the hook. Make sure the type that will be returned and the type of the first argument of the hook are the same.

    Returns this

Generated using TypeDoc