ioBroker.javascript icon indicating copy to clipboard operation
ioBroker.javascript copied to clipboard

[Feature Request] QueryResult.on with parameters

Open BenjaminHae opened this issue 5 years ago • 0 comments

Currently, when using the on method of a QueryResult from $ it only accepts the callback as parameter: on(callback: StateChangeHandler): this;
This presets some values of the pattern that is passed to the on procedure to default values. For example "change":"ne" so you can't just use on of a QueryResult to subscribe to any state change of the result.

I propose changing the on method of QueryResult to have an optional parameter conditions that is of a new type SubscribeConditions.
This type would contain a subset of elements of the current SubscribeOptions interface. The SubscribeOptions interface should then just be an extension of the new SubscribeConditions interface.

It is currently possible to achieve the same by implementing it like this:

const temperature = $('[role=value.temperature]');
temperature.each(function(id, i) {
    on({"id":[id], "change": "any"}, callback);
});

BenjaminHae avatar Aug 08 '20 15:08 BenjaminHae