Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@splitsoftware/splitio-redux

Package Overview
Dependencies
Maintainers
5
Versions
80
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@splitsoftware/splitio-redux - npm Package Compare versions

Comparing version 1.1.0-canary.0 to 1.1.0-canary.1

2

CHANGES.txt

@@ -1,2 +0,2 @@

1.1.0 (May 8, 2020)
1.1.0 (May 11, 2020)
- Bugfixing - incorrect evaluation of splits on browser when using `getTreatments` with a different user key than the default, caused by not waiting the fetch of segments.

@@ -3,0 +3,0 @@ - Added `destroySplitSdk` action creator to gracefully shutdown the SDK.

import { SplitFactory } from '@splitsoftware/splitio';
import { splitReady, splitTimedout, splitUpdate, splitDestroy, addTreatments } from './actions';
import { VERSION, ERROR_GETT_NO_INITSPLITSDK, ERROR_DESTROY_NO_INITSPLITSDK, getControlTreatmentsWithConfig } from './constants';
import { matching } from './utils';
import { matching, promiseWrapper } from './utils';
export const splitSdk = {

@@ -55,3 +55,6 @@ config: null,

// Return the promise so that the user can call .then() on async dispatch result and wait until ready.
return defaultClient.ready();
return promiseWrapper(new Promise(function (res, rej) {
defaultClient.once(defaultClient.Event.SDK_READY, res);
defaultClient.once(defaultClient.Event.SDK_READY_TIMED_OUT, rej);
}), function () { });
};

@@ -178,3 +181,3 @@ }

* This action creator destroy the Split SDK. It dispatches a Thunk (async) action.
* After this action is resolved, any subsequent dispatch of `getTreatments`
* Once the action is resolved, any subsequent dispatch of `getTreatments`
* will update your treatments at the store with the `control` value.

@@ -181,0 +184,0 @@ */

// Default value for the key where the Split piece of state is expected to be mounted.
export const DEFAULT_SPLIT_STATE_SLICE = 'splitio';
export const VERSION = 'redux-' + '1.1.0-canary.0';
export const VERSION = 'redux-' + '1.1.0-canary.1';
// Treatments

@@ -5,0 +5,0 @@ export const ON = 'on';

@@ -13,1 +13,36 @@ /**

}
/**
* wraps a given promise in a new promise with a default onRejected function,
* that handles the promise rejection if not other onRejected handler is provided.
*
* @param customPromise promise to wrap
* @param defaultOnRejected default onRejected function
*/
export function promiseWrapper(customPromise, defaultOnRejected) {
let hasCatch = false;
function chain(promise) {
const newPromise = new Promise((res, rej) => {
return promise.then(res, function (value) {
if (hasCatch) {
rej(value);
}
else {
defaultOnRejected(value);
}
});
});
const originalThen = newPromise.then;
newPromise.then = function (onfulfilled, onrejected) {
const result = originalThen.call(newPromise, onfulfilled, onrejected);
if (typeof onrejected === 'function') {
hasCatch = true;
return result;
}
else {
return chain(result);
}
};
return newPromise;
}
return chain(customPromise);
}

@@ -55,3 +55,3 @@ import { Dispatch, Action } from 'redux';

* This action creator destroy the Split SDK. It dispatches a Thunk (async) action.
* After this action is resolved, any subsequent dispatch of `getTreatments`
* Once the action is resolved, any subsequent dispatch of `getTreatments`
* will update your treatments at the store with the `control` value.

@@ -58,0 +58,0 @@ */

@@ -68,3 +68,6 @@ "use strict";

// Return the promise so that the user can call .then() on async dispatch result and wait until ready.
return defaultClient.ready();
return utils_1.promiseWrapper(new Promise(function (res, rej) {
defaultClient.once(defaultClient.Event.SDK_READY, res);
defaultClient.once(defaultClient.Event.SDK_READY_TIMED_OUT, rej);
}), function () { });
};

@@ -196,3 +199,3 @@ }

* This action creator destroy the Split SDK. It dispatches a Thunk (async) action.
* After this action is resolved, any subsequent dispatch of `getTreatments`
* Once the action is resolved, any subsequent dispatch of `getTreatments`
* will update your treatments at the store with the `control` value.

@@ -199,0 +202,0 @@ */

@@ -5,3 +5,3 @@ "use strict";

exports.DEFAULT_SPLIT_STATE_SLICE = 'splitio';
exports.VERSION = 'redux-' + '1.1.0-canary.0';
exports.VERSION = 'redux-' + '1.1.0-canary.1';
// Treatments

@@ -8,0 +8,0 @@ exports.ON = 'on';

@@ -9,1 +9,9 @@ /**

export declare function matching(key: SplitIO.SplitKey): string;
/**
* wraps a given promise in a new promise with a default onRejected function,
* that handles the promise rejection if not other onRejected handler is provided.
*
* @param customPromise promise to wrap
* @param defaultOnRejected default onRejected function
*/
export declare function promiseWrapper(customPromise: Promise<any>, defaultOnRejected: (_: any) => any): Promise<any>;

@@ -17,1 +17,37 @@ "use strict";

exports.matching = matching;
/**
* wraps a given promise in a new promise with a default onRejected function,
* that handles the promise rejection if not other onRejected handler is provided.
*
* @param customPromise promise to wrap
* @param defaultOnRejected default onRejected function
*/
function promiseWrapper(customPromise, defaultOnRejected) {
var hasCatch = false;
function chain(promise) {
var newPromise = new Promise(function (res, rej) {
return promise.then(res, function (value) {
if (hasCatch) {
rej(value);
}
else {
defaultOnRejected(value);
}
});
});
var originalThen = newPromise.then;
newPromise.then = function (onfulfilled, onrejected) {
var result = originalThen.call(newPromise, onfulfilled, onrejected);
if (typeof onrejected === 'function') {
hasCatch = true;
return result;
}
else {
return chain(result);
}
};
return newPromise;
}
return chain(customPromise);
}
exports.promiseWrapper = promiseWrapper;
{
"name": "@splitsoftware/splitio-redux",
"version": "1.1.0-canary.0",
"version": "1.1.0-canary.1",
"description": "A library to easily use Split JS SDK with Redux and React Redux",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc