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

this is being shadowed in _onSocketMessage in several branches. #39

Open
jeffreydwalter opened this issue Jan 11, 2018 · 5 comments
Open

Comments

@jeffreydwalter
Copy link

In the initial branch, _onSocketMessage refers to this._postsView.addPosts(), which works fine.
In later branches, this._postsView.addPosts() is wrapped in other promises and loses it's scope.

Here's one example in Lesson 4, step 7 (task-clean-db branch):

this._postsView.addPosts(messages);

The fix is to assign this to var indexController = this; as is being done in the rest of the code.

@jeffreydwalter
Copy link
Author

I saw this in at least one other branch earlier but fixed it without really thinking to report it as a bug.

For clarity and consistency sake, you guys should probably just make that assignment in _onSocketMessage() (all the functions in IndexController really) from the very first lesson, even though it's not strictly needed, since you do that in most of the other functions.

@jeffreydwalter
Copy link
Author

I created a PR to address this issue in task-clean-db. #40

@jeffreydwalter
Copy link
Author

The error message you see in the console is:
image

@jeffreydwalter
Copy link
Author

I left a post in the Udacity forums about this issue as well.

@jeffreydwalter
Copy link
Author

Just realized this issue was caused by me moving this._postsView.addPosts(messages); inside this._dbPromise.then(function(db), which is clearly wrong.

I'd still argue that making the var indexController = this; assignment would be good form.

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

No branches or pull requests

1 participant