Feature Description
This is an issue that I've already risen in the past proposing to add ability to pass arbitrary keys engine.setValue and engine.setParameter but this seem to have met some opposition.
So I'd like to start a broader discussion about adding an API to do reactive programming in controller especially now that I started working on ES6+ components JS.
What I propose is to reflect on a standard API for Mixxx, setting aside the implementation. This API could mimic ES Event API with methods like dispatchEvent, addEventListener and removeEventListener a be closer to Qt's signals/slots API (also I'm not sure what this would look like…).
This API could be standard to Component and ComponentContainer.
Regarding the implementation, I propose a first implementation in pure JS using EventTarget, CustomEvent and Proxy (this seem supported by Mixxx' JS engine, also I need to formally check) as follows:
class Component {
__signals = new (class extends EventTarget {
constructor() {
super();
return new Proxy(this, {
set: (target, property, value) => {
const previousValue = target[property];
target[property] = value;
this.dispatchEvent(new CustomEvent(property, { detail: {value, previousValue} }));
return true;
},
});
}
})();
connect(name, callback) {
this.__signals.addEventListener(name, (evt) => {
callback(name, evt.detail.value, evt.detail.previousValue)
})
}
}
that could be transparantly replaced by a C++ implem in the engine namespace thanks to the standard API.
Feature Description
This is an issue that I've already risen in the past proposing to add ability to pass arbitrary keys
engine.setValueandengine.setParameterbut this seem to have met some opposition.So I'd like to start a broader discussion about adding an API to do reactive programming in controller especially now that I started working on ES6+ components JS.
What I propose is to reflect on a standard API for Mixxx, setting aside the implementation. This API could mimic ES
EventAPI with methods likedispatchEvent,addEventListenerandremoveEventListenera be closer to Qt's signals/slots API (also I'm not sure what this would look like…).This API could be standard to
ComponentandComponentContainer.Regarding the implementation, I propose a first implementation in pure JS using
EventTarget,CustomEventandProxy(this seem supported by Mixxx' JS engine, also I need to formally check) as follows:that could be transparantly replaced by a C++ implem in the
enginenamespace thanks to the standard API.