configcat-react
Advanced tools
Comparing version 4.8.0 to 4.8.1
@@ -52,10 +52,13 @@ "use client"; | ||
var Version_1 = __importDefault(require("./Version")); | ||
var initializedClients = new Map(); | ||
var ConfigCatProvider = /** @class */ (function (_super) { | ||
__extends(ConfigCatProvider, _super); | ||
function ConfigCatProvider(props) { | ||
var _this = _super.call(this, props) || this; | ||
var client = !isServerContext() | ||
var _this = this; | ||
var _a; | ||
_this = _super.call(this, props) || this; | ||
var client = (!isServerContext() | ||
? _this.initializeConfigCatClient() | ||
: new ConfigCatClientStub(); | ||
: new ConfigCatClientStub()); | ||
var providers = (_a = client.$reactSdk_providers) !== null && _a !== void 0 ? _a : (client.$reactSdk_providers = new Set()); | ||
providers.add(_this); | ||
_this.state = { client: client }; | ||
@@ -66,5 +69,2 @@ return _this; | ||
var _this = this; | ||
var _a; | ||
var sdkKey = this.props.sdkKey; | ||
initializedClients.set(sdkKey, ((_a = initializedClients.get(sdkKey)) !== null && _a !== void 0 ? _a : 0) + 1); | ||
this.configChangedHandler = function (newConfig) { return _this.reactConfigChanged(newConfig); }; | ||
@@ -81,3 +81,2 @@ this.state.client.waitForReady().then(function () { | ||
ConfigCatProvider.prototype.componentWillUnmount = function () { | ||
var _a; | ||
if (this.configChangedHandler) { | ||
@@ -87,8 +86,5 @@ this.state.client.off("configChanged", this.configChangedHandler); | ||
} | ||
var sdkKey = this.props.sdkKey; | ||
var refCount = ((_a = initializedClients.get(sdkKey)) !== null && _a !== void 0 ? _a : 1) - 1; | ||
initializedClients.set(sdkKey, refCount); | ||
if (refCount <= 0) { | ||
var providers = this.state.client.$reactSdk_providers; | ||
if ((providers === null || providers === void 0 ? void 0 : providers.delete(this)) && !providers.size) { | ||
this.state.client.dispose(); | ||
initializedClients.delete(sdkKey); | ||
} | ||
@@ -95,0 +91,0 @@ }; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.default = "4.8.0"; | ||
exports.default = "4.8.1"; |
@@ -23,10 +23,13 @@ "use client"; | ||
import CONFIGCAT_SDK_VERSION from "./Version"; | ||
var initializedClients = new Map(); | ||
var ConfigCatProvider = /** @class */ (function (_super) { | ||
__extends(ConfigCatProvider, _super); | ||
function ConfigCatProvider(props) { | ||
var _this = _super.call(this, props) || this; | ||
var client = !isServerContext() | ||
var _this = this; | ||
var _a; | ||
_this = _super.call(this, props) || this; | ||
var client = (!isServerContext() | ||
? _this.initializeConfigCatClient() | ||
: new ConfigCatClientStub(); | ||
: new ConfigCatClientStub()); | ||
var providers = (_a = client.$reactSdk_providers) !== null && _a !== void 0 ? _a : (client.$reactSdk_providers = new Set()); | ||
providers.add(_this); | ||
_this.state = { client: client }; | ||
@@ -37,5 +40,2 @@ return _this; | ||
var _this = this; | ||
var _a; | ||
var sdkKey = this.props.sdkKey; | ||
initializedClients.set(sdkKey, ((_a = initializedClients.get(sdkKey)) !== null && _a !== void 0 ? _a : 0) + 1); | ||
this.configChangedHandler = function (newConfig) { return _this.reactConfigChanged(newConfig); }; | ||
@@ -52,3 +52,2 @@ this.state.client.waitForReady().then(function () { | ||
ConfigCatProvider.prototype.componentWillUnmount = function () { | ||
var _a; | ||
if (this.configChangedHandler) { | ||
@@ -58,8 +57,5 @@ this.state.client.off("configChanged", this.configChangedHandler); | ||
} | ||
var sdkKey = this.props.sdkKey; | ||
var refCount = ((_a = initializedClients.get(sdkKey)) !== null && _a !== void 0 ? _a : 1) - 1; | ||
initializedClients.set(sdkKey, refCount); | ||
if (refCount <= 0) { | ||
var providers = this.state.client.$reactSdk_providers; | ||
if ((providers === null || providers === void 0 ? void 0 : providers.delete(this)) && !providers.size) { | ||
this.state.client.dispose(); | ||
initializedClients.delete(sdkKey); | ||
} | ||
@@ -66,0 +62,0 @@ }; |
@@ -1,1 +0,1 @@ | ||
export default "4.8.0"; | ||
export default "4.8.1"; |
{ | ||
"name": "configcat-react", | ||
"version": "4.8.0", | ||
"version": "4.8.1", | ||
"scripts": { | ||
@@ -5,0 +5,0 @@ "build": "npm run build:esm && npm run build:cjs", |
Sorry, the diff of this file is not supported yet
89400
1419