https://www.growthbook.io/ logo
#ask-questions
Title
# ask-questions
h

happy-postman-12006

10/17/2023, 8:42 AM
Another simpler question: is there a way to check whether the features have been loaded? Something like
growthbookClient.isFeaturesLoaded
s

straight-whale-38038

10/17/2023, 9:17 AM
you can await the promise
gb.loadFeatures()
h

happy-postman-12006

10/17/2023, 9:19 AM
Yup, that seems to be the only option for now. I wanted to avoid this since I would like to check the state in different places in the code. I looked through the code and it doesn't seem trivial to get the loading state, since a bunch of internal state would have to be exposed between the
this._loadFeaturesCalled
and the
activeFetches
Map. Thanks for your response.
Was hoping for something like how Tanstack Query exposes these loading state flags.
👍 1
s

straight-whale-38038

10/17/2023, 9:20 AM
Oh, I see. I think you could handle your GB instance as a Singleton and add a property that checks if it's already loaded
And every time gb.loadFeatures() run successfully you update your local
isFeaturesLoaded
value
h

happy-postman-12006

10/17/2023, 9:21 AM
Cool, thanks, I should be able to get something like that up and running 👍
🙂 1
Might be useful to others: there is a
ready
flag exposed on the growthbook instance that seems to do the same thing.
16 Views