Container for a context/contexts. Because contexts come from external code they must be thoroughly validated and then formed to comply with the type system.

Hierarchy

  • Context

Constructors

  • Contexts should be created using the static factory method Context.fromLDContext.

    Parameters

    • valid: boolean
    • kind: string

      The kind of the context.

      The factory methods are static functions within the class because they access private implementation details, so they cannot be free functions.

    • Optional message: string
      Optional

    Returns Context

Properties

context?: LDContextCommon
contexts: Record<string, LDContextCommon> = {}
isMulti: boolean = false
isUser: boolean = false
kind: string
message?: string
privateAttributeReferences?: Record<string, AttributeReference[]>
valid: boolean

Is this a valid context. If a valid context cannot be created, then this flag will be true. The validity of a context should be tested before it is used.

wasLegacy: boolean = false
userKind: string = DEFAULT_KIND

Accessors

Methods

  • Attempt to get a key for the specified kind.

    Parameters

    • kind: string = DEFAULT_KIND

      The kind to get a key for.

    Returns undefined | string

    The key for the specified kind, or undefined.

  • Attempt to get a value for the given context kind using the given reference.

    Parameters

    • reference: AttributeReference

      The reference to the value to get.

    • kind: string = DEFAULT_KIND

      The kind of the context to get the value for.

    Returns any

    a value or undefined if one is not found.

Generated using TypeDoc