Skip to content

Commit

Permalink
support closure action because sendAction is deprecated
Browse files Browse the repository at this point in the history
  • Loading branch information
scottkidder committed Sep 21, 2018
1 parent a5af209 commit 7af24a0
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions addon/components/range-slider.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,20 @@ export default Component.extend({
this.slider = slider;

sliderEvents.forEach(event => {
if (!isEmpty(this.get(`on-${event}`))) {
const eventActionName = `on-${event}`;

if (!isEmpty(this.get(eventActionName))) {
slider.on(event, () => {
run(this, function() {
let val = this.get("slider").get();
this.sendAction(`on-${event}`, val);
const val = this.get('slider').get();
const action = this.get(eventActionName);

if (typeof(action) === 'string') {
// Note that `sendAction` is deprecated and this will trigger a deprecation message.
this.sendAction(eventActionName, val);
} else if (typeof(action) === 'function') {
action(val);
}
});
});
}
Expand Down

0 comments on commit 7af24a0

Please sign in to comment.