identify method

Future<IdentifyResult> identify(
  1. LDContext context, {
  2. bool waitForNetworkResults = false,
})

Changes the active context.

When the context is changed, the SDK will load flag values for the context from a local cache if available, while initiating a connection to retrieve the most current flag values. An event will be queued to be sent to the service containing the public LDContext fields for indexing on the dashboard.

A context with the same kinds and same keys will use the same cached context.

This returned future can be awaited to wait for the identify process to be complete. As with start this can take an extended period if there is not network availability, so a timeout is recommended.

The waitForNetworkResults parameters, when true, indicates that the SDK will attempt to wait for values from LaunchDarkly instead of depending on cached values. The cached values will still be loaded, but the future returned by this function will not resolve as a result of those cached values being loaded. Generally this option should NOT be used and instead flag changes should be listened to. It the client is set to offline mode, then this option is ignored.

If waitForNetworkResults is true, and an error is encountered, then IdentifyError may be returned even if cached values were loaded.

The identify will complete with 1 of three possible values: IdentifyComplete, IdentifySuperseded, or IdentifyError.

IdentifyComplete means that the SDK has managed to identify the user and either is using cached values or has received new values from LaunchDarkly.

IdentifySuperseded means that additional identify calls have been made and this specific call has been cancelled. If identify multiple contexts without waiting for the previous identify to complete, then you may get this result. For instance if you called identify 10 times rapidly, then it is likely that 2 total identifies would complete, the first one and the last one. The intermediates would be cancelled for performance.

IdentifyError this means that the identify has permanently failed. For instance the SDK key is no longer valid.

Implementation

Future<IdentifyResult> identify(LDContext context,
    {bool waitForNetworkResults = false}) async {
  return _client.identify(context,
      waitForNetworkResults: waitForNetworkResults);
}