-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: getprecomputedinstance should always return an instance #151
Changes from all commits
c18f5b4
f5d4eb4
84fd645
438ea47
534566b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -557,7 +557,13 @@ export function getConfigUrl(apiKey: string, baseUrl?: string): URL { | |
* @public | ||
*/ | ||
export class EppoPrecomputedJSClient extends EppoPrecomputedClient { | ||
public static instance: EppoPrecomputedJSClient; | ||
public static instance = new EppoPrecomputedJSClient({ | ||
precomputedFlagStore: memoryOnlyPrecomputedFlagsStore, | ||
subject: { | ||
subjectKey: '', | ||
subjectAttributes: {}, | ||
}, | ||
}); | ||
public static initialized = false; | ||
|
||
public getStringAssignment(flagKey: string, defaultValue: string): string { | ||
|
@@ -609,7 +615,7 @@ export class EppoPrecomputedJSClient extends EppoPrecomputedClient { | |
export async function precomputedInit( | ||
config: IPrecomputedClientConfig, | ||
): Promise<EppoPrecomputedClient> { | ||
if (EppoPrecomputedJSClient.instance) { | ||
if (EppoPrecomputedJSClient.initialized) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Another bit of feedback was about "shutting down" the client #117 (comment) Since the client instance now will always be defined, I am switching to use the |
||
return EppoPrecomputedJSClient.instance; | ||
} | ||
|
||
|
@@ -764,7 +770,7 @@ export function offlinePrecomputedInit( | |
} | ||
|
||
function shutdownEppoPrecomputedClient() { | ||
if (EppoPrecomputedJSClient.instance && EppoPrecomputedJSClient.initialized) { | ||
if (EppoPrecomputedJSClient.initialized) { | ||
EppoPrecomputedJSClient.instance.stopPolling(); | ||
EppoPrecomputedJSClient.initialized = false; | ||
applicationLogger.warn('[Eppo SDK] Precomputed client is being re-initialized.'); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just to confirm, this instantiation doesn't kick off any network requests or polling, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope, you have to go through the
precomputedInit
method to start the poller