Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cleanup watch methodes #16359

Merged
merged 1 commit into from
Mar 24, 2018
Merged

Conversation

bekzod
Copy link
Contributor

@bekzod bekzod commented Mar 10, 2018

removes some work from #14571
since then I think root cause might have been fixed

@@ -16,8 +16,6 @@ import {
let handleMandatorySetter;

export function watchKey(obj, keyName, _meta) {
if (typeof obj !== 'object' || obj === null) { return; }
Copy link
Contributor Author

@bekzod bekzod Mar 10, 2018

Choose a reason for hiding this comment

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

since meta has assertion for non-object / non-function values

assert(`Cannot call \`meta\` on ${typeof obj}`, typeof obj === 'object' || typeof obj === 'function');

IMHO, it is better to assert than be silent to uncover unnecessary/invalid calls of watchKey

Copy link
Contributor

Choose a reason for hiding this comment

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

does the assert check for null objects?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes

assert('Cannot call `meta` on null', obj !== null);

@@ -79,9 +77,6 @@ if (MANDATORY_SETTER) {
}

export function unwatchKey(obj, keyName, _meta) {
if (typeof obj !== 'object' || obj === null) {
Copy link
Contributor Author

@bekzod bekzod Mar 10, 2018

Choose a reason for hiding this comment

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

since peekMeta has assertion for non-object / non-function values, it is better to assert than be silent to uncover invalid calls of unwatchKey

Copy link
Member

@mmun mmun Mar 11, 2018

Choose a reason for hiding this comment

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

Yes, I agree, though we should check that this doesn't cause any crashes in a few real world apps before it gets into beta. Can you check that ember observer works correctly with this PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

will do

Copy link
Contributor Author

Choose a reason for hiding this comment

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

checked in both emberobserver and emberaddons, both working properly and no regression in benchmarks https://cl.ly/441V333w3R3R/results.pdf

@rwjblue rwjblue requested a review from mmun March 10, 2018 14:36
@krisselden krisselden merged commit d49f3ed into emberjs:master Mar 24, 2018
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.

3 participants