new EvolvClient(opts)
The EvolvClient provides a low level integration with the Evolv participant APIs.
The client provides asynchronous access to key states, values, contexts, and configurations.
Parameters:
Name | Type | Description |
---|---|---|
opts |
Partial.<EvolvClientOptions> |
An object of options for the client. |
Members
(inner, constant) beaconOptions :Partial.<EmitterOptions>
Methods
allowEvents()
If the client was configured with bufferEvents: true then calling this will allow data to be sent back to Evolv
clearActiveKeys(prefixopt)
Clears the active keys to reset the key states.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
prefix |
String |
<optional> |
The prefix of the keys clear. |
confirm()
Confirm that the consumer has successfully received and applied values, making them eligible for inclusion in optimization statistics.
contaminate(detailsopt, allExperimentsopt)
Marks a consumer as unsuccessfully retrieving and / or applying requested values, making them ineligible for inclusion in optimization statistics.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
details |
Object |
<optional> |
Information on the reason for contamination. If provided, the object should contain a reason. Optionally, a 'details' value should be included for extra debugging info |
|
allExperiments |
boolean |
<optional> |
false |
If true, the user will be excluded from all optimizations, including optimization not applicable to this page |
destroy()
Destroy the client and its dependencies.
emit(type, metadataopt, flushopt)
Send an event to the events endpoint.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
type |
String |
The type associated with the event. |
||
metadata |
Object |
<optional> |
Any metadata to attach to the event. |
|
flush |
Boolean |
<optional> |
false |
If true, the event will be sent immediately. |
flush()
Force all beacons to transmit.
get(key) → {SubscribablePromise.<(*|Error)>}
Get the value of a specified key.
Parameters:
Name | Type | Description |
---|---|---|
key |
String |
The key of the value to retrieve. |
getActiveKeys(prefixopt) → {SubscribablePromise.<({current: Array.<string>, previous: Array.<string>}|Error)>}
Check all active keys that start with the specified prefix.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
prefix |
String |
<optional> |
The prefix of the keys to check. |
getConfig(key) → {SubscribablePromise.<(*|Error)>}
Get the configuration for a specified key.
Parameters:
Name | Type | Description |
---|---|---|
key |
String |
The key to retrieve the configuration for. |
getDisplayName(type, key) → {SubscribablePromise.<(*|Error)>}
Get the display name for a specified type and key.
Parameters:
Name | Type | Description |
---|---|---|
type |
String |
The type of entity we're retrieving the display name for. Allow values: 'experiments' |
key |
String |
The key/id to retrieve the display name for. |
getEnvConfig(key) → {SubscribablePromise.<(*|Error)>}
Get the configuration for a specified key.
Parameters:
Name | Type | Description |
---|---|---|
key |
String |
The key of the property to retrieve. |
initialize(uid, remoteContextopt, localContextopt)
Initializes the client with required context information.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
uid |
String |
A globally unique identifier for the current participant. |
|
remoteContext |
Object |
<optional> |
A map of data used for evaluating context predicates and analytics. |
localContext |
Object |
<optional> |
A map of data used only for evaluating context predicates. |
isActive(key) → {SubscribablePromise.<(Boolean|Error)>}
Check if a specified key is currently active.
Parameters:
Name | Type | Description |
---|---|---|
key |
String |
The key to check. |
off(topic, listener)
Remove a listener from a lifecycle event.
See the "on" function for supported events.
Parameters:
Name | Type | Description |
---|---|---|
topic |
String |
The event topic from which the listener should be removed. |
listener |
Listener |
The listener to be removed from the specified topic. |
- Source:
- See:
-
- EvolvClient#on for listeners that should be invoked on each event.
on(topic, listener)
Add listeners to lifecycle events that take place in to client.
Currently supported events:
- "initialized" - Called when the client is fully initialized and ready for use with (topic, options)
- "context.initialized" - Called when the context is fully initialized and ready for use with (topic, updated_context)
- "context.changed" - Called whenever a change is made to the context values with (topic, updated_context)
- "context.value.removed" - Called when a value is removed from context with (topic, key, updated_context)
- "context.value.added" - Called when a new value is added to the context with (topic, key, value, local, updated_context)
- "context.value.changed" - Called when a value is changed in the context (topic, key, value, before, local, updated_context)
- "context.destroyed" - Called when the context is destroyed with (topic, context)
- "genome.request.sent" - Called when a request for a genome is sent with (topic, requested_keys)
- "config.request.sent" - Called when a request for a config is sent with (topic, requested_keys)
- "genome.request.received" - Called when the result of a request for a genome is received (topic, requested_keys)
- "config.request.received" - Called when the result of a request for a config is received (topic, requested_keys)
- "request.failed" - Called when a request fails (topic, source, requested_keys, error)
- "genome.updated" - Called when the stored genome is updated (topic, allocation_response)
- "config.updated" - Called when the stored config is updated (topic, config_response)
- "effective.genome.updated" - Called when the effective genome is updated (topic, effectiveGenome)
- "store.destroyed" - Called when the store is destroyed (topic, store)
- "confirmed" - Called when the consumer is confirmed (topic)
- "contaminated" - Called when the consumer is contaminated (topic)
- "event.emitted" - Called when an event is emitted through the beacon (topic, type, score)
Parameters:
Name | Type | Description |
---|---|---|
topic |
String |
The event topic on which the listener should be invoked. |
listener |
Listener |
The listener to be invoked for the specified topic. |
- Source:
- See:
-
- EvolvClient#once for listeners that should only be invoked once.
once(topic, listener)
Add a listener to a lifecycle event to be invoked once on the next instance of the event to take place in to client.
See the "on" function for supported events.
Parameters:
Name | Type | Description |
---|---|---|
topic |
String |
The event topic on which the listener should be invoked. |
listener |
Listener |
The listener to be invoked for the specified topic. |
- Source:
- See:
-
- EvolvClient#on for listeners that should be invoked on each event.
preload(prefixes, configOnlyopt, immediateopt)
Preload all keys under the specified prefixes.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
prefixes |
Array.<String> |
A list of prefixes to keys to load. |
||
configOnly |
Boolean |
<optional> |
false |
If true, only the config would be loaded. |
immediate |
Boolean |
<optional> |
false |
Forces the requests to the server. |
reevaluateContext()
Reevaluates the current context.