Skip to content

Reduce Evented complexity#217

Merged
RobbieTheWagner merged 2 commits intomasterfrom
reduce-complexity
Aug 23, 2018
Merged

Reduce Evented complexity#217
RobbieTheWagner merged 2 commits intomasterfrom
reduce-complexity

Conversation

@RobbieTheWagner
Copy link
Member

No description provided.

Copy link
Member

@chuckcarpenter chuckcarpenter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall seems good. Just wondering if the old typeof checks should be replaced with a check for the type we're expecting.

const once = arguments.length <= 3 || arguments[3] === undefined ? false : arguments[3];

if (typeof this.bindings === 'undefined') {
if (_.isUndefined(this.bindings)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Think the original intent is to check if it's an object, perhaps that one instead?


off(event, handler) {
if (typeof this.bindings === 'undefined' || typeof this.bindings[event] === 'undefined') {
if (_.isUndefined(this.bindings) || _.isUndefined(this.bindings[event])) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same for this first statement

for (let _key = 1; _key < _len; _key++) {
args[_key - 1] = arguments[_key];
}
this.bindings[event].forEach((binding, index) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so much easier to read.

@RobbieTheWagner RobbieTheWagner merged commit 89e83e9 into master Aug 23, 2018
@RobbieTheWagner RobbieTheWagner deleted the reduce-complexity branch August 23, 2018 22:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants