Class: LaunchDarkly::Impl::FlagTracker Private
- Inherits:
-
Object
- Object
- LaunchDarkly::Impl::FlagTracker
- Extended by:
- Forwardable
- Includes:
- LaunchDarkly::Interfaces::FlagTracker
- Defined in:
- lib/ldclient-rb/impl/flag_tracker.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Defined Under Namespace
Classes: FlagValueChangeAdapter
Instance Method Summary collapse
- #add_flag_value_change_listener(key, context, listener) ⇒ Object private
-
#add_listener(listener) ⇒ Object
included
from LaunchDarkly::Interfaces::FlagTracker
Registers a listener to be notified of feature flag changes in general.
-
#initialize(broadcaster, eval_fn) ⇒ FlagTracker
constructor
private
A new instance of FlagTracker.
-
#remove_listener(listener) ⇒ Object
included
from LaunchDarkly::Interfaces::FlagTracker
Unregisters a listener so that it will no longer be notified of feature flag changes.
Constructor Details
#initialize(broadcaster, eval_fn) ⇒ FlagTracker
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of FlagTracker.
13 14 15 16 |
# File 'lib/ldclient-rb/impl/flag_tracker.rb', line 13 def initialize(broadcaster, eval_fn) @broadcaster = broadcaster @eval_fn = eval_fn end |
Instance Method Details
#add_flag_value_change_listener(key, context, listener) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
18 19 20 21 22 23 |
# File 'lib/ldclient-rb/impl/flag_tracker.rb', line 18 def add_flag_value_change_listener(key, context, listener) flag_change_listener = FlagValueChangeAdapter.new(key, context, listener, @eval_fn) add_listener(flag_change_listener) flag_change_listener end |
#add_listener(listener) ⇒ Object Originally defined in module LaunchDarkly::Interfaces::FlagTracker
Registers a listener to be notified of feature flag changes in general.
The listener will be notified whenever the SDK receives any change to any feature flag's configuration, or to a user segment that is referenced by a feature flag. If the updated flag is used as a prerequisite for other flags, the SDK assumes that those flags may now behave differently and sends flag change events for them as well.
Note that this does not necessarily mean the flag's value has changed for any particular evaluation context, only that some part of the flag configuration was changed so that it may return a different value than it previously returned for some context. If you want to track flag value changes, use #add_flag_value_change_listener instead.
It is possible, given current design restrictions, that a listener might be notified when no change has occurred. This edge case will be addressed in a later version of the SDK. It is important to note this issue does not affect #add_flag_value_change_listener listeners.
If using the file data source, any change in a data file will be treated as a change to every flag. Again, use #add_flag_value_change_listener (or just re-evaluate the flag # yourself) if you want to know whether this is a change that really affects a flag's value.
Change events only work if the SDK is actually connecting to LaunchDarkly (or using the file data source). If the SDK is only reading flags from a database then it cannot know when there is a change, because flags are read on an as-needed basis.
The listener will be called from a worker thread.
Calling this method for an already-registered listener has no effect.
#remove_listener(listener) ⇒ Object Originally defined in module LaunchDarkly::Interfaces::FlagTracker
Unregisters a listener so that it will no longer be notified of feature flag changes.
Calling this method for a listener that was not previously registered has no effect.