Skip to content

Commit

Permalink
Merge pull request #68 from scottkidder/use-closure-actions
Browse files Browse the repository at this point in the history
Support closure actions because sendAction is deprecated
  • Loading branch information
kennethkalmer authored Nov 9, 2018
2 parents f64c42c + 8bf355c commit bd191ee
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 @@ -86,11 +86,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 bd191ee

Please sign in to comment.