Skip to content

feat (Optimizely) [OASIS-5907]: close promise tracks in-flight event dispatcher requests #404

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 19, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions packages/optimizely-sdk/CHANGELOG.MD
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
### Bug fixes
- Fixed default event dispatcher not used in React Native entry point ([#383](https://github.com/optimizely/javascript-sdk/pull/383))

### New Features
- Promise returned from `close` tracks the state of in-flight event dispatcher requests ([#404](https://github.com/optimizely/javascript-sdk/pull/404))

## [3.4.1] - January 28th, 2020

### Bug fixes
Expand Down
21 changes: 11 additions & 10 deletions packages/optimizely-sdk/lib/optimizely/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -935,20 +935,21 @@ Optimizely.prototype.getOptimizelyConfig = function() {
* - Pending event queue flushes
*
* In-flight datafile requests will be aborted. Any events waiting to be sent
* as part of a batched event request will be immediately batched and sent to
* the event dispatcher.
* as part of a batched event request will be immediately flushed to the event
* dispatcher.
*
* If any such requests were sent to the event dispatcher, returns a Promise
* that fulfills after the event dispatcher calls the response callback for each
* request. Otherwise, returns an immediately-fulfilled Promise.
* Returns a Promise that fulfills after all in-flight event dispatcher requests
* (including any final request resulting from flushing the queue as described
* above) are complete. If there are no in-flight event dispatcher requests and
* no queued events waiting to be sent, returns an immediately-fulfilled Promise.
*
* Returned Promises are fulfilled with result objects containing these
* properties:
* - success (boolean): true if all events in the queue at the time close was
* called were combined into requests, sent to the
* event dispatcher, and the event dispatcher called the
* callbacks for each request. false if an unexpected
* error was encountered during the close process.
* - success (boolean): true if the event dispatcher signaled completion of
* all in-flight and final requests, or if there were no
* queued events and no in-flight requests. false if an
* unexpected error was encountered during the close
* process.
* - reason (string=): If success is false, this is a string property with
* an explanatory message.
*
Expand Down
6 changes: 3 additions & 3 deletions packages/optimizely-sdk/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/optimizely-sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"homepage": "https://github.com/optimizely/javascript-sdk/tree/master/packages/optimizely-sdk",
"dependencies": {
"@optimizely/js-sdk-datafile-manager": "^0.4.0",
"@optimizely/js-sdk-event-processor": "^0.3.0",
"@optimizely/js-sdk-event-processor": "^0.4.0",
"@optimizely/js-sdk-logging": "^0.1.0",
"@optimizely/js-sdk-utils": "^0.2.0",
"json-schema": "^0.2.3",
Expand Down