Hook

public protocol Hook

Protocol for extending SDK functionality via hooks.

  • metadata() Default implementation

    Get metadata about the hook implementation.

    Default Implementation

    Get metadata about the hook implementation.

    Declaration

    Swift

    func metadata() -> Metadata
  • Executed by the SDK at the start of the evaluation of a feature flag.

    This is not executed as part of a call to LDClient.allFlags().

    To provide custom data to the series which will be given back to your Hook at the next stage of the series, return a dictionary containing the custom data. You should initialize this dictionary from the seriesData.

    Default Implementation

    The before method is called during the execution of a variation method before the flag value has been determined. The method is executed synchronously.

    Declaration

    Swift

    func beforeEvaluation(seriesContext: EvaluationSeriesContext, seriesData: EvaluationSeriesData) -> EvaluationSeriesData

    Parameters

    seriesContext

    Container of parameters associated with this evaluation.

    seriesData

    Immutable data from the previous stage in the evaluation series. beforeEvaluation is the first stage in this series, so this will be an empty dictionary.

    Return Value

    A dictionary containing custom data that will be carried through to the next stage of the series.

  • Executed by the SDK after the evaluation of a feature flag completes.

    This is not executed as part of a call to LDClient.allFlags().

    This is currently the last stage of the evaluation series in the Hook, but that may not be the case in the future. To ensure forward compatibility, return the seriesData unmodified.

    Default Implementation

    The after method is called during the execution of the variation method after the flag value has been determined. The method is executed synchronously.

    Declaration

    Swift

    func afterEvaluation(seriesContext: EvaluationSeriesContext, seriesData: EvaluationSeriesData, evaluationDetail: LDEvaluationDetail<LDValue>) -> EvaluationSeriesData

    Parameters

    seriesContext

    Container of parameters associated with this evaluation.

    seriesData

    Immutable data from the previous stage in the evaluation series.

    evaluationDetail

    The result of the evaluation that took place before this hook was invoked.

    Return Value

    A dictionary containing custom data that will be carried through to the next stage of the series (if added in the future).

  • To provide custom data to the series which will be given back to your Hook at the next stage of the series, return a dictionary containing the custom data. You should initialize this dictionary from the seriesData.

    Default Implementation

    Called during the execution of the identify process before the operation completes, but after any context modifications are performed.

    Default implementation is a no-op that returns seriesData unchanged.

    Declaration

    Swift

    func beforeIdentify(seriesContext: IdentifySeriesContext, seriesData: IdentifySeriesData) -> IdentifySeriesData

    Parameters

    seriesContext

    Contains information about the identify operation being performed. This is not mutable.

    seriesData

    A record associated with each stage of hook invocations. Each stage is called with the data of the previous stage for a series. The input record should not be modified.

    Return Value

    A dictionary containing custom data that will be carried through to the next stage of the series.

  • Called during the execution of the identify process, after the operation completes.

    This is currently the last stage of the identify series in the Hook, but that may not be the case in the future. To ensure forward compatibility, return the seriesData unmodified.

    Default Implementation

    Called during the execution of the identify process, after the operation completes.

    Default implementation is a no-op that returns seriesData unchanged.

    Declaration

    Swift

    func afterIdentify(seriesContext: IdentifySeriesContext, seriesData: IdentifySeriesData, result: IdentifyResult) -> IdentifySeriesData

    Parameters

    seriesContext

    Contains information about the identify operation being performed. This is not mutable.

    seriesData

    A record associated with each stage of hook invocations. Each stage is called with the data of the previous stage for a series. The input record should not be modified.

    result

    The result of the identify operation.

    Return Value

    A dictionary containing custom data that will be carried through to the next stage of the series (if added in the future).