Skip to content

Commit 63ed7b1

Browse files
authored
prepare 1.6.0 release (#74)
1 parent b7cd9c4 commit 63ed7b1

File tree

9 files changed

+575
-88
lines changed

9 files changed

+575
-88
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
All notable changes to the LaunchDarkly client-side JavaScript SDK will be documented in this file. This
44
project adheres to [Semantic Versioning](http://semver.org).
55

6+
## [1.6.0] - 2018-03-28
7+
### Changed
8+
- Added support for a future update to LaunchDarkly that will deliver individual feature flag changes over the streaming connection as they occur, rather than requiring the client to re-request all flags for each change.
9+
610
## [1.5.2] - 2018-03-28
711
### Added
812
- The new flush method on the client object tells the client to deliver any stored analytics events as soon as possible, rather than waiting for the regularly scheduled event-flushing interval.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ldclient-js",
3-
"version": "1.5.2",
3+
"version": "1.6.0",
44
"description": "LaunchDarkly SDK for JavaScript",
55
"author": "LaunchDarkly <[email protected]>",
66
"license": "Apache-2.0",

src/Requestor.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,12 @@ function Requestor(baseUrl, environment, useReport) {
5555
}
5656

5757
var wrappedCallback = (function(currentCallback) {
58-
return function() {
59-
currentCallback.apply(null, arguments);
58+
return function(error, result) {
59+
// if we got flags, convert them to the more verbose format used by the eval stream
60+
if (result) {
61+
result = utils.transformValuesToVersionedValues(result);
62+
}
63+
currentCallback(error, result);
6064
flagSettingsRequest = null;
6165
lastFlagSettingsCallback = null;
6266
};

src/Stream.js

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,29 @@
1-
function Stream(url, environment) {
1+
var utils = require('./utils');
2+
3+
function Stream(baseUrl, environment, hash, useReport) {
24
var stream = {};
3-
var url = url + '/ping/' + environment;
5+
var evalUrlPrefix = baseUrl + '/eval/' + environment + '/';
46
var es = null;
57

6-
stream.connect = function(onPing) {
8+
stream.connect = function(user, handlers) {
79
if (typeof EventSource !== 'undefined') {
10+
var url;
11+
if (useReport) {
12+
// we don't yet have an EventSource implementation that supports REPORT, so
13+
// fall back to the old ping-based stream
14+
url = baseUrl + '/ping/' + environment;
15+
} else {
16+
url = evalUrlPrefix + utils.base64URLEncode(JSON.stringify(user));
17+
if (hash !== null && hash !== undefined) {
18+
url = url + '?h=' + hash;
19+
}
20+
}
821
es = new window.EventSource(url);
9-
es.addEventListener('ping', onPing);
22+
for (var key in handlers) {
23+
if (handlers.hasOwnProperty(key)) {
24+
es.addEventListener(key, handlers[key]);
25+
}
26+
}
1027
}
1128
}
1229

0 commit comments

Comments
 (0)