Hook
public protocol Hook
Protocol for extending SDK functionality via hooks.
-
metadata()Default implementationGet metadata about the hook implementation.
Default Implementation
Get metadata about the hook implementation.
Declaration
Swift
func metadata() -> Metadata -
beforeEvaluation(seriesContext:Default implementationseriesData: ) 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) -> EvaluationSeriesDataParameters
seriesContextContainer of parameters associated with this evaluation.
seriesDataImmutable data from the previous stage in the evaluation series.
beforeEvaluationis 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.
-
afterEvaluation(seriesContext:Default implementationseriesData: evaluationDetail: ) 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
seriesDataunmodified.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>) -> EvaluationSeriesDataParameters
seriesContextContainer of parameters associated with this evaluation.
seriesDataImmutable data from the previous stage in the evaluation series.
evaluationDetailThe 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).
-
beforeIdentify(seriesContext:Default implementationseriesData: ) 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
seriesDataunchanged.Declaration
Swift
func beforeIdentify(seriesContext: IdentifySeriesContext, seriesData: IdentifySeriesData) -> IdentifySeriesDataParameters
seriesContextContains information about the identify operation being performed. This is not mutable.
seriesDataA 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.
-
afterIdentify(seriesContext:Default implementationseriesData: result: ) 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
seriesDataunmodified.Default Implementation
Called during the execution of the identify process, after the operation completes.
Default implementation is a no-op that returns
seriesDataunchanged.Declaration
Swift
func afterIdentify(seriesContext: IdentifySeriesContext, seriesData: IdentifySeriesData, result: IdentifyResult) -> IdentifySeriesDataParameters
seriesContextContains information about the identify operation being performed. This is not mutable.
seriesDataA 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.
resultThe 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).
View on GitHub