You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
By default, Harness Feature Flags SDK has streaming enabled and polling enabled. Both modes can be toggled according to your preference using the SDK's configuration.
82
82
83
83
### Streaming Mode
84
-
Streaming mode establishes a continuous connection between your application and the Feature Flags service.
85
-
This allows for real-time updates on feature flags without requiring periodic checks.
84
+
Streaming mode establishes a continuous connection between your application and the Feature Flags service.
85
+
This allows for real-time updates on feature flags without requiring periodic checks.
86
86
If an error occurs while streaming and `pollingEnabled` is set to `true`,
87
-
the SDK will automatically fall back to polling mode until streaming can be reestablished.
87
+
the SDK will automatically fall back to polling mode until streaming can be reestablished.
88
88
If `pollingEnabled` is `false`, streaming will attempt to reconnect without falling back to polling.
89
89
90
90
### Polling Mode
91
91
In polling mode, the SDK will periodically check with the Feature Flags service to retrieve updates for feature flags. The frequency of these checks can be adjusted using the SDK's configurations.
92
92
93
93
### No Streaming or Polling
94
-
If both streaming and polling modes are disabled (`streamEnabled: false` and `pollingEnabled: false`),
95
-
the SDK will not automatically fetch feature flag updates after the initial fetch.
94
+
If both streaming and polling modes are disabled (`streamEnabled: false` and `pollingEnabled: false`),
95
+
the SDK will not automatically fetch feature flag updates after the initial fetch.
96
96
This means that after the initial load, any changes made to the feature flags on the Harness server will not be reflected in the application until the SDK is re-initialized or one of the modes is re-enabled.
97
97
98
-
This configuration might be useful in specific scenarios where you want to ensure a consistent set of feature flags
98
+
This configuration might be useful in specific scenarios where you want to ensure a consistent set of feature flags
99
99
for a session or when the application operates in an environment where regular updates are not necessary. However, it's essential to be aware that this configuration can lead to outdated flag evaluations if the flags change on the server.
100
100
101
101
To configure the modes:
@@ -127,9 +127,9 @@ You can configure the maximum number of streaming retries before the SDK stops a
127
127
```typescript
128
128
const options = {
129
129
maxRetries: 5, // Set the maximum number of retries for streaming. Default is Infinity.
// Event happens when connection has been lost and reestablished
176
+
// Event happens when connection has been lost and reestablished
177
177
})
178
178
179
179
client.on(Event.POLLING, () => {
@@ -238,7 +238,7 @@ For the example above, if the flag identifier 'Dark_Theme' is not found, result
238
238
}
239
239
```
240
240
241
-
If you do not need to know the default variation was returned:
241
+
If you do not need to know the default variation was returned:
242
242
243
243
```typescript
244
244
const variationValue =client.variation('Dark_Theme', false) // second argument is default value when variation does not exist
@@ -257,7 +257,7 @@ For the example above:
257
257
3. Wrong project API key being used
258
258
259
259
#### Listening for the `ERROR_DEFAULT_VARIATION_RETURNED` event
260
-
You can also listen for the `ERROR_DEFAULT_VARIATION_RETURNED` event, which is emitted whenever a default variation is returned because the flag has not been found in the cache. This is useful for logging or taking other action when a flag is not found.
260
+
You can also listen for the `ERROR_DEFAULT_VARIATION_RETURNED` event, which is emitted whenever a default variation is returned because the flag has not been found in the cache. This is useful for logging or taking other action when a flag is not found.
261
261
262
262
Example of listening for the event:
263
263
@@ -386,7 +386,7 @@ const client = initialize(
386
386
```
387
387
388
388
## API Middleware
389
-
The `registerAPIRequestMiddleware` function allows you to register a middleware function to manipulate the payload (URL, body and headers) of API requests after the AUTH call has successfully completed
389
+
The `registerAPIRequestMiddleware` function allows you to register a middleware function to manipulate the payload (URL, body and headers) of API requests.
390
390
391
391
```typescript
392
392
function abortControllerMiddleware([url, options]) {
0 commit comments