LDContext
public struct LDContext : Encodable, Equatable
extension LDContext: Decodable
LDContext is a collection of attributes that can be referenced in flag evaluations and analytics events.
To create an LDContext of a single kind, such as a user, you may use LDContextBuilder
.
To create an LDContext with multiple kinds, use LDMultiContextBuilder
.
-
Declaration
Swift
public func encode(to encoder: Encoder) throws
-
FullyQualifiedKey returns a string that describes the entire Context based on Kind and Key values.
This value is used whenever LaunchDarkly needs a string identifier based on all of the Kind and Key values in the context; the SDK may use this for caching previously seen contexts, for instance.
Declaration
Swift
public func fullyQualifiedKey() -> String
-
Declaration
Swift
public func isMulti() -> Bool
Return Value
true if the
LDContext
is a multi-context; false otherwise. -
/ - Returns: A hash mapping a context’s kind to its key.
Declaration
Swift
public func contextKeys() -> [String : String]
-
Looks up the value of any attribute of the
LDContext
, or a value contained within an attribute, based on aReference
. This includes only attributes that are addressable in evaluations.This implements the same behavior that the SDK uses to resolve attribute references during a flag evaluation. In a context, the
Reference
can represent a simple attribute name– either a built-in one like “name” or “key”, or a custom attribute that was set byLDContextBuilder.trySetValue(...)
– or, it can be a slash-delimited path using a JSON-Pointer-like syntax. SeeReference
for more details.For a multi-context, the only supported attribute name is “kind”.
If the value is found, the return value is the attribute value, using the type
LDValue
to represent a value of any JSON type.If there is no such attribute, or if the
Reference
is invalid, the return value is nil. -
Declaration
Swift
public init(from decoder: Decoder) throws