@unleash/proxy-client-svelte
Advanced tools
Comparing version 0.2.0 to 0.3.0
/// <reference types="svelte" /> | ||
declare const useVariant: (name: string) => import("svelte/store").Writable<import("unleash-proxy-client").IVariant>; | ||
import type { IVariant } from 'unleash-proxy-client'; | ||
declare const useVariant: (name: string) => import("svelte/store").Writable<IVariant>; | ||
export default useVariant; |
import { getContext } from 'svelte'; | ||
import { writable, get } from 'svelte/store'; | ||
import { ContextStateSymbol } from './context.js'; | ||
const variantHasChanged = (oldVariant, newVariant) => { | ||
const variantsAreEqual = oldVariant.name === newVariant?.name && | ||
oldVariant.enabled === newVariant?.enabled && | ||
oldVariant.feature_enabled === newVariant?.feature_enabled && | ||
oldVariant.payload?.type === newVariant?.payload?.type && | ||
oldVariant.payload?.value === newVariant?.payload?.value; | ||
return !variantsAreEqual; | ||
}; | ||
const useVariant = (name) => { | ||
@@ -12,3 +20,3 @@ const { getVariant, client } = getContext(ContextStateSymbol); | ||
const currentVariant = get(variantStore); | ||
if (newVariant?.name !== currentVariant.name || newVariant.enabled !== currentVariant.enabled) { | ||
if (variantHasChanged(currentVariant, newVariant)) { | ||
variantStore.set(newVariant); | ||
@@ -15,0 +23,0 @@ } |
{ | ||
"name": "@unleash/proxy-client-svelte", | ||
"version": "0.2.0", | ||
"version": "0.3.0", | ||
"description": "Svelte interface for working with Unleash", | ||
@@ -53,3 +53,3 @@ "repository": { | ||
"dependencies": { | ||
"unleash-proxy-client": "^2.5.0" | ||
"unleash-proxy-client": "^3.2.0" | ||
}, | ||
@@ -56,0 +56,0 @@ "svelte": "./dist/index.js", |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
15361
142
0
+ Addedunleash-proxy-client@3.7.3(transitive)
+ Addeduuid@9.0.1(transitive)
- Removedunleash-proxy-client@2.5.0(transitive)
- Removeduuid@8.3.2(transitive)
Updatedunleash-proxy-client@^3.2.0