Skip to content

Commit

Permalink
prepare 1.6.0 release (#74)
Browse files Browse the repository at this point in the history
  • Loading branch information
eli-darkly authored Mar 28, 2018
1 parent b7cd9c4 commit 63ed7b1
Show file tree
Hide file tree
Showing 9 changed files with 575 additions and 88 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
All notable changes to the LaunchDarkly client-side JavaScript SDK will be documented in this file. This
project adheres to [Semantic Versioning](http://semver.org).

## [1.6.0] - 2018-03-28
### Changed
- 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.

## [1.5.2] - 2018-03-28
### Added
- 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.
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ldclient-js",
"version": "1.5.2",
"version": "1.6.0",
"description": "LaunchDarkly SDK for JavaScript",
"author": "LaunchDarkly <[email protected]>",
"license": "Apache-2.0",
Expand Down
8 changes: 6 additions & 2 deletions src/Requestor.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,12 @@ function Requestor(baseUrl, environment, useReport) {
}

var wrappedCallback = (function(currentCallback) {
return function() {
currentCallback.apply(null, arguments);
return function(error, result) {
// if we got flags, convert them to the more verbose format used by the eval stream
if (result) {
result = utils.transformValuesToVersionedValues(result);
}
currentCallback(error, result);
flagSettingsRequest = null;
lastFlagSettingsCallback = null;
};
Expand Down
25 changes: 21 additions & 4 deletions src/Stream.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,29 @@
function Stream(url, environment) {
var utils = require('./utils');

function Stream(baseUrl, environment, hash, useReport) {
var stream = {};
var url = url + '/ping/' + environment;
var evalUrlPrefix = baseUrl + '/eval/' + environment + '/';
var es = null;

stream.connect = function(onPing) {
stream.connect = function(user, handlers) {
if (typeof EventSource !== 'undefined') {
var url;
if (useReport) {
// we don't yet have an EventSource implementation that supports REPORT, so
// fall back to the old ping-based stream
url = baseUrl + '/ping/' + environment;
} else {
url = evalUrlPrefix + utils.base64URLEncode(JSON.stringify(user));
if (hash !== null && hash !== undefined) {
url = url + '?h=' + hash;
}
}
es = new window.EventSource(url);
es.addEventListener('ping', onPing);
for (var key in handlers) {
if (handlers.hasOwnProperty(key)) {
es.addEventListener(key, handlers[key]);
}
}
}
}

Expand Down
Loading

0 comments on commit 63ed7b1

Please sign in to comment.