aomran / ember-cli-zero-clipboard

Ember CLI addon for adding a "copy to clipboard" button component
https://www.npmjs.org/package/ember-cli-zero-clipboard
17 stars 12 forks source link

Use sendAction instead of send #13

Closed alex88 closed 8 years ago

alex88 commented 9 years ago

Shouldn't the component use sendAction instead of send? So the user can skip having an afterCopy action or bind it to another name and also, not having an error when the action is not defined?

aomran commented 9 years ago

@alex88 you're right that we should be using the public API method sendAction here.

alex88 commented 9 years ago

It will break current implementation thought, since users will have to bind the afterCopy action manually, will you plan to release this in next major release or what?

aomran commented 9 years ago

sendAction is for sending said actions to a controller. I think the proper way of doing this is to call methods directly on the component.

So for example we'll define a function called afterCopy that you can override when extending the component.

alex88 commented 9 years ago

Can you give me an example of that? If you don't bind the action on the controller nothing happens and the user can bind the afterCopy action to whatever he wants and for every component instance

aomran commented 9 years ago

I think the latest implementation might be a good fix for now until this is refactored in a major release: https://github.com/aomra015/ember-cli-zero-clipboard/blob/master/addon/components/zero-clipboard.js#L14

Basically it will try to send the action, recover and then log the error.