open-feature / open-feature/spec

Subscribe to variable updates

Open
#346 8 comments 3 reactions 4 assignees View on GitHub

@kinyoklion is already working on this.

Since Oct 21, 2025.

Dominant language
Python
Stars
1.3k
Forks
58
Avg merge
2d 18h
Merged PRs (30d)
2

Description

Feature request

When working with DevCycle I have come to notice that OpenFeature doesn't have a convenient way for subscribing to updates of a certain variable similar to DevCycle's variable updates:

var variable: Variable<String> = devcycleClient.variable("str_key", "default")
variable.onUpdate {
    // grab the variable value using it.value
}

Source code

The Events API provides generic callbacks only currently

What the Events spec provides is a global mechanism for listening to updates in general:

The data that providers supply in event payloads may include a list of flag keys changed, error messages, and possibly updated flag values. [See the Event details data type]

Kotlin example:

var myFlag = OpenFeatureAPI.getClient().getBooleanValue("myflag", ...)
OpenFeatureAPI.observe().onEach { event ->
  if(event.eventDetails?.flagsChanged.contains("myflag")) {
    myFlag = OpenFeatureAPI.getClient().getBooleanValue("myflag", ...)
}

So as you can see it's quite a bit of boilerplate for just tracking the values of one variable. And you have to ask fetch the new value again, it's not part of the event payload, making this idiom less convenient.

Motivation

As an application developer I would like to activate/deactivate features of my long-running client-side apps instantaneously. My app is not restarted for days or weeks, so I'd like to subscribe to variable changes in my application code.

Proposal

Some reactive API could be added to the Flag Evaluation API, which is convenient to use as an app developer, such as:

class MyClass {
  private var subscription: ...

  fun init() {
    subscription = OpenFeatureAPI.getClient().onBooleanValueChanges("myflag", "default", { oldValue, newValue ->
      // do some stuff with newValue
      updateUI(newValue)
    })
  }

  fun close() {
    subscription.close()
  }
}

P.S.: If you like the suggestion, feel free to pick up this topic, I won't have much time in the coming weeks for contribution.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.