Skip to content

Commit

Permalink
replace sendAction with modern callable methods
Browse files Browse the repository at this point in the history
  • Loading branch information
donaldwasserman committed Oct 9, 2018
1 parent f5a1848 commit 6e7515b
Show file tree
Hide file tree
Showing 5 changed files with 1,536 additions and 18 deletions.
8 changes: 6 additions & 2 deletions addon/components/light-table.js
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,10 @@ const LightTable = Component.extend({
}
},

// No-ops for closure actions
onBeforeResponsiveChange() {},
onAfterResponsiveChange() {},

actions: {
/**
* onBeforeResponsiveChange action.
Expand All @@ -329,7 +333,7 @@ const LightTable = Component.extend({
* @param {Array} matches list of matching breakpoints
*/
onBeforeResponsiveChange(/* matches */) {
this.sendAction('onBeforeResponsiveChange', ...arguments);
this.onBeforeResponsiveChange(...arguments);
},

/**
Expand All @@ -340,7 +344,7 @@ const LightTable = Component.extend({
* @param {Array} matches list of matching breakpoints
*/
onAfterResponsiveChange(/* matches */) {
this.sendAction('onAfterResponsiveChange', ...arguments);
this.onAfterResponsiveChange(...arguments);
}
}
});
Expand Down
29 changes: 19 additions & 10 deletions addon/components/lt-body.js
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ export default Component.extend({
This debounce is needed when there is not enough delay between onScrolledToBottom calls.
Without this debounce, all rows will be rendered causing immense performance problems
*/
this._debounceTimer = run.debounce(this, this.sendAction, 'onScrolledToBottom', delay);
this._debounceTimer = run.debounce(this, this.onScrolledToBottom, delay);
},

/**
Expand All @@ -445,6 +445,15 @@ export default Component.extend({
run.cancel(this._debounceTimer);
},

// Noop for closure actions
onRowClick() {},
onRowDoubleClick() {},
onScroll() {},
lastVisibleChanged() {},
firstReached() {},
lastReached() {},
onScrolledToBottom() {},

actions: {
/**
* onRowClick action. Handles selection, and row expansion.
Expand Down Expand Up @@ -489,7 +498,7 @@ export default Component.extend({
toggleExpandedRow();
}

this.sendAction('onRowClick', ...arguments);
this.onRowClick(...arguments);
},

/**
Expand All @@ -499,7 +508,7 @@ export default Component.extend({
* @param {Event} event The click event
*/
onRowDoubleClick(/* row */) {
this.sendAction('onRowDoubleClick', ...arguments);
this.onRowDoubleClick(...arguments);
},

/**
Expand All @@ -514,7 +523,7 @@ export default Component.extend({
*/
onScroll(scrollOffset /* , event */) {
this.set('currentScrollOffset', scrollOffset);
this.sendAction('onScroll', ...arguments);
this.onScroll(...arguments);
},

/**
Expand All @@ -533,22 +542,22 @@ export default Component.extend({
},

firstVisibleChanged(item, index /* , key */) {
this.sendAction('firstVisibleChanged', ...arguments);
this.firstVisibleChanged(...arguments);
const estimateScrollOffset = index * this.get('sharedOptions.estimatedRowHeight');
this.sendAction('onScroll', estimateScrollOffset, null);
this.onScroll(estimateScrollOffset, null);
},

lastVisibleChanged(/* item, index, key */) {
this.sendAction('lastVisibleChanged', ...arguments);
this.lastVisibleChanged(...arguments);
},

firstReached(/* item, index, key */) {
this.sendAction('firstReached', ...arguments);
this.firstReached(...arguments);
},

lastReached(/* item, index, key */) {
this.sendAction('lastReached', ...arguments);
this.sendAction('onScrolledToBottom');
this.lastReached(...arguments);
this.onScrolledToBottom();
}
}
});
7 changes: 5 additions & 2 deletions addon/components/lt-column-resizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export default Component.extend({
this.set('isResizing', false);
this.set('column.width', width);

this.sendAction('onColumnResized', width);
this.onColumnResized(width);
this.$().closest(TOP_LEVEL_CLASS).removeClass('is-resizing');
}
},
Expand All @@ -97,5 +97,8 @@ export default Component.extend({
$(`tbody td:nth-child(${$index})`, $table).outerWidth(width);
}
}
}
},

// No-op for closure actions
onColumnResized() {}
});
12 changes: 8 additions & 4 deletions addon/mixins/draggable-column.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export default Mixin.create({

sourceColumn = column;
this.set('isDragging', true);
this.sendAction('onColumnDrag', sourceColumn, ...arguments);
this.onColumnDrag(sourceColumn, ...arguments);

/*
NOTE: This is a fix for Firefox to prevent the click event
Expand Down Expand Up @@ -107,7 +107,7 @@ export default Mixin.create({
drop did not happen.
*/
if (sourceColumn) {
this.sendAction('onColumnDrop', sourceColumn, false, ...arguments);
this.onColumnDrop(sourceColumn, false, ...arguments);
sourceColumn = null;
}

Expand Down Expand Up @@ -142,13 +142,17 @@ export default Mixin.create({

this.setProperties({ isDragTarget: false, isDragging: false });

this.sendAction('onColumnDrop', sourceColumn, true, ...arguments);
this.onColumnDrop(sourceColumn, true, ...arguments);
sourceColumn = null;
}
},

destroy() {
this._super(...arguments);
run.cancel(this._clickResetTimer);
}
},

// Noop for passed actions
onColumnDrag() {},
onColumnDrop() {}
});
Loading

0 comments on commit 6e7515b

Please sign in to comment.