node-dmx / dmx

DMX controller library for node.js
MIT License
297 stars 96 forks source link

Added extraData parameter to update method and event #96

Closed DoctorMcKay closed 4 years ago

DoctorMcKay commented 4 years ago

I'm currently building my own DMX controller software, and my use-case for this origin parameter is to be able to distinguish between what triggered an update. If the update was triggered by an animation, I want to replicate that data to the UI, but if the update was triggered by the UI, then I don't want to update the UI unnecessarily.

wiedi commented 4 years ago

Sounds useful.

I'm wondering if this should be a generic "extra_data" object (instead of a string) that the library passes along but doesn't make any assumption about. Then origin could be one property of that object. And if some other information would be needed it could be added without a furthe API change.

Please also don't forget to document this change in the readme.

DoctorMcKay commented 4 years ago

That sounds like a good idea to me. Will update later.

I think I'm also going to submit a separate pull request to add a hook when updating a channel so that the channel's value can be modified e.g. according to a master fader.

DoctorMcKay commented 4 years ago

I've pushed some commits to change the origin argument to extraData as suggested, with animations setting the origin property to the string 'animation'.

I've also updated the tests and readme.

wiedi commented 4 years ago

Thank you! And apologies for the delay.