flagsmith-nodejs-client
flagsmith-nodejs-client copied to clipboard
Local Evaluation without awaiting a Promise
- ~rm whitespace~
- ~rm superfluous updateEnvironment(); this was called 2x in local evaluation mode startup. Let the polling manager make the first call.~
- add
getIdentityFlagsSync(); expects local evaluation or offline mode, and a synchronous cache. Does not return a Promise. - add
readyCheck()Wait for the environment document to load. If the request fails then this promise is rejected. Useful for local evaluation mode.
I was rather confused that, with local evaluation mode, retrieving flags is still an async operation! Promises are entirely unnecessary in this particular situation. In fact, it forces any calling code to be async too which can be quite annoying. Once the environment document is first loaded, I should be able to check my flags in a simple synchronous fashion, while the environment updates in the background.
const flagsmith = new Flagsmith({
enableLocalEvaluation: true
})
// need to wait for first load
await flagsmith.readyCheck()
// now evaluate with in-memory document
const flags = flagsmith.getIdentityFlagsSync('unknown_user')
console.log(flags)
Before I proceed any further with this (adding tests, better docs). Is this idea likely to be merged?
Before I proceed any further with this (adding tests, better docs). Is this idea likely to be merged?
Yes, this certainly seems like a good idea to me! We would love for you to continue, and we would definitely consider merging.
@cody-greene Are you able to work on this? If not I'll close?
Yes. I'll find some time to finish this
-------- Original Message -------- On Mar 20, 2024, 2:57 AM, Ben Rometsch wrote:
@.***(https://github.com/cody-greene) Are you able to work on this? If not I'll close?
— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.Message ID: @.***>
I will convert this PR to a draft in the meantime. Please feel free to change it to Ready for Review whenever it gets completed.
@cody-greene I am closing this PR since it has not been active for a long time. Please feel free to re-open once you have a new version as per the above comments.