ftlabs / fruitmachine

View rendering engine
MIT License
247 stars 18 forks source link

How do we distinguish firing events that bubble from those that don't (or can't) #19

Closed matthew-andrews closed 11 years ago

matthew-andrews commented 11 years ago

There are some events that can't bubble, eg:

But custom fruit machine module events should bubble through the fruit machine structure by default.

The way this works is 0.3 is by passing in an object with a propagate option set to either true or false.

this.fire('render', { propagate: false });

@wilsonpage and @SamGiles prefer:

this.fire('buttonclick');
this.fireStatic('render');

As most use cases of fireStatic are internal anyway.


I think I like:

this.emit('buttonclick');
this.publish('render'); // or fire('render'); is ok too

This keeps public functions of the FruitMachine API consistently single worded (perhaps fireStatic doesn't need to be public?). However this has the disadvantage of requiring all existing use of fire within our fruit to be change to be emit's.

This issue can probably closed already because in balance fireStatic / fire is probably the best option.

samgiles commented 11 years ago

After much thought, I prefer the current version this.fire('render', { propagate: false });. Purely because:

An aside: emit to me seems more like a synonym of the proposed fireStatic. Publish is something that goes to everything, and, for example 'light emitted is blocked by the first opaque thing it encounters', therefore emit is more like fireStatic, publish more like fire.

matthew-andrews commented 11 years ago

On reflection fireStatic/fire or the current implementation seem like the best.