-
Notifications
You must be signed in to change notification settings - Fork 12
Introduced ObservableMixin#decorate() and support for fire()'s return values #163
Conversation
src/observablemixin.js
Outdated
* | ||
* @param {String} ...methodNames Names of the methods to decorate. | ||
*/ | ||
decorate( ...methodNames ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would keep it simple: we don't expect many methods to be decorated at the same time, so I don't find it needed to add handling multiple methods at the same time by this function. Also, it would be a problem if we will want to add some parameters to it in the future.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I actually took that into consideration. I think that if we'd add options it would become an object anyway:
decorate( { name: 'foo', how: 'bar' } )
But perhaps you're right that support for decorating multiple methods at once is an overkill. I'll remove that.
src/emittermixin.js
Outdated
@@ -135,6 +135,9 @@ const EmitterMixin = { | |||
* the priority value the sooner the callback will be fired. Events having the same priority are called in the | |||
* order they were added. | |||
* @param {Object} [options.context] The object that represents `this` in the callback. Defaults to the object firing the event. | |||
* @returns By default the method returns `undefined`. However, the return value can be changed by listeners | |||
* through modification of the {@link module:utils/emitterinfo~EmitterInfo#return}'s value (the event info | |||
* is the first param of every callback). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should be docs for fire
not for listenTo
. However, a comment here and next to the on
method about how callback can set the return value would be fine (most probably a link to the return property docs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Haha. Good catch.
When working on tests for ckeditor5-core I stumbled upon a case where I tried to spy on To avoid such issues I'll make |
Back on review. |
One last doubt – the |
Wrong button :D |
Suggested merge commit message (convention)
Feature: Introduced
ObservableMixin#decorate()
and support for settingEmitterMixin#fire()
's return value by listeners. Closes ckeditor/ckeditor5#4958.