Another simpler question: is there a way to check ...
# ask-questions
h
Another simpler question: is there a way to check whether the features have been loaded? Something like
growthbookClient.isFeaturesLoaded
s
you can await the promise
gb.loadFeatures()
h
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
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
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.