From 673fe9122d890da887896d18e659a6dfa68deb24 Mon Sep 17 00:00:00 2001 From: Kim Gustyr Date: Wed, 21 Aug 2024 14:12:53 +0100 Subject: [PATCH] add `updateContext` --- flagsmith-core.ts | 7 +++++++ types.d.ts | 5 +++++ 2 files changed, 12 insertions(+) diff --git a/flagsmith-core.ts b/flagsmith-core.ts index bb18c5f..423ab67 100644 --- a/flagsmith-core.ts +++ b/flagsmith-core.ts @@ -667,6 +667,13 @@ const Flagsmith = class { return this.evaluationContext; } + updateContext = (evaluationContext: EvaluationContext) => { + return this.setContext({ + ...this.getContext(), + ...evaluationContext, + }) + } + setTrait = (key: string, trait_value: IFlagsmithTrait) => { const { api } = this; diff --git a/types.d.ts b/types.d.ts index 407548a..9a8c039 100644 --- a/types.d.ts +++ b/types.d.ts @@ -143,6 +143,11 @@ export interface IFlagsmith Promise; + /** + * Merge current evaluation context with the provided one. Refresh the flags. + */ + updateContext: () => Promise; + /** /** * Get current context. */