speckling
v1.0.0
Published
Create a custom dom event and send duplicates to all elements with a specified css class.
Downloads
11
Maintainers
Readme
speckling
Create a custom dom event and send duplicate copies of the event to all elements with a specified css class.
#example
var speckle = require('speckling');
speckle('some madeup event', '.elm_class');
All elements with class .elm_class will receive a 'some madeup event' event.
Why would I want to do this?
This is intended to be used as a way for multiple components to communicate with each other while being loosely coupled.
I really liked the idea behind twitter's flight framework, but felt it was too complicated and didn't like its dependence on jquery, and I had trouble getting it to play nice with browserify. I usally prefer just working with the standard web apis as it reduces my cognitive load since I am not spending a huge amount of time trying to figure out how the hell things work.
...But you are firing so many events that may not be needed! Won't this scale poorely?
There is truth to that statement, but scaling poorely can be a good thing. For example, if you encounter this issue, you should ask yourself if your front end ui stuff isn't a little too complicated and should maybe be simplified further.