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.
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.