Varx – Reactive Extensions (Rx) for JUCE

varx – Reactive Extensions (Rx) for JUCE

Hi everyone! I’ve created a JUCE module called varx that brings Reactive Extensions (Rx) to JUCE. This helps to connect our app’s user interface, parameters and audio processing in a simple, flexible and consistent way. It reduces boilerplate code and errors.

Get it for free on GitHub!

So what does it do?
For example, let’s say we want to update a Label text whenever a Slider is moved.
Normally you have to inherit from Slider::Listener, call slider.addListener(this) in your constructor, override sliderValueChanged, and call label.setText() from there.

With varx however, it’s just one line of code:

slider.rx.value.map(valueToString).subscribe(label.rx.text);

This connects the Label text to the Slider and makes sure it stays up-to-date. (More details in the README on GitHub)

It’s not limited to GUI components: You can connect any value, and things stay in sync. For more examples, please refer to the Getting Started guide.

If you already know Rx: varx has Observables with all the common operators, Observers and Subjects.

varx is released under the MIT license. I appreciate your feedback and any questions.

12 Likes

Brilliant work, look forward to trying this out in my current project.

I’m interested especially in having direct reactive connections to elements in a ValueTree, instead of using the sometimes unwieldy (and verbose) ValueTree::Listener overrides.

This looks fantastic and will come in very handy. :smiley: Thank you for sharing this. :heart:

1 Like

That’s interesting…could you please describe how you use the ValueTree: Do you use nested ValueTrees, and what events do you need to be notified about?

Yes, I do use nested ValueTrees, however I think most of the time subscribing to the Value of a ValueTree property would be sufficient. It would also be useful to be able subscribe to the events from ValueTree::Listener for some cases.

1 Like

great jobs