Other Protocols

The following protocols are available globally.

  • Protocol indicting a type can be converted into an LDValue.

    Types used with the LDClient.variation(forKey: defaultValue:) or LDClient.variationDetail(forKey: detailValue:) methods are required to implement this protocol. This protocol has already been implemented for Bool, Int, Double, String, and LDValue types.

    This allows custom types as evaluation result types while retaining the LDValue type throughout the event processing system.

    See more

    Declaration

    Swift

    public protocol LDValueConvertible
  • Protocol for extending SDK functionality via hooks.

    See more

    Declaration

    Swift

    public protocol Hook
  • Protocol for extending SDK functionality via plugins.

    Plugins provide a way to extend the functionality of the LaunchDarkly SDK. A plugin can register hooks that are called during flag evaluation, and can perform initialization when registered with a client instance.

    Plugin implementations should be thread-safe as they may be called concurrently from multiple threads.

    Usage Example

    class MyPlugin: Plugin {
        func getMetadata() -> PluginMetadata {
            return PluginMetadata(name: "MyPlugin")
        }
    
        func register(client: LDClient, metadata: EnvironmentMetadata) {
            // Perform plugin initialization
        }
    
        func getHooks(metadata: EnvironmentMetadata) -> [Hook] {
            return [MyHook()]
        }
    }
    
    let config = LDConfig.Builder(mobileKey: "your-mobile-key")
        .plugins([MyPlugin()])
        .build()
    
    See more

    Declaration

    Swift

    public protocol Plugin