Closed nadavkaner closed 5 years ago
There actually is such a mechanism. The client will emit an event called "update:MY_FLAG_KEY"
for each specific flag that's changed, as well as a general "update"
event for any flag change; to listen for these events you would just do client.on(nameOfEvent, callback)
.
There are a few issues:
on
method out of the TypeScript definitions in index.d.ts
, so if you're using TypeScript it won't be available to you until we fix that.js-client
change event, it can't tell you what the new value of the flag is— because that varies per user, and the server-side SDKs don't have any notion of a "current user." So the event will just be telling you that the definition of the flag has changed, and then you would need to call variation
with a specific user in order to see what the value is now for that user (which, depending on what was changed in the flag, might end up being the same value as before). This makes the update events somewhat less useful in a server-side context, which is one reason we haven't implemented them more widely yet.Correction to the previous comment: the on
and off
methods were always available in TypeScript, because LDClient
inherits from EventEmitter
.
Also, these events are now documented in the TypeScript declarations for the SDK (index.d.ts
) which currently are the best reference for all existing methods and properties. Once we have online generated documentation, this information will be there too.
It will be nice to have the ability to listen to change events like there is in the js-client.