Skip to content

Commit

Permalink
add updateContext
Browse files Browse the repository at this point in the history
  • Loading branch information
khvn26 committed Sep 19, 2024
1 parent df987b3 commit 673fe91
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
7 changes: 7 additions & 0 deletions flagsmith-core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
5 changes: 5 additions & 0 deletions types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,11 @@ export interface IFlagsmith<F extends string = string, T extends string = string
* Set evaluation context. Refresh the flags.
*/
setContext: (context: EvaluationContext) => Promise<void>;
/**
* Merge current evaluation context with the provided one. Refresh the flags.
*/
updateContext: () => Promise<void>;
/**
/**
* Get current context.
*/
Expand Down

0 comments on commit 673fe91

Please sign in to comment.