Closed seanpoulter closed 5 years ago
After those fixes, the output still doesn't match what's expected from Exercise 35. 😓
Expected Result
[{
"name": "Thrillers",
"videos": [234324, 234322314, 23, 5, 435, 12, 3, 234, 34, 23324]
}, {
"name": "New Releases",
"videos": [234324, 234322314, 23, 5, 435, 12, 3, 234, 34, 23324]
}, {
"name": "Instant Queue",
"videos": [234324, 234322314, 23, 5, 435, 12, 3, 234, 34, 23324]
}]
Actual Result
{
"2": {
"name": "Instant Queue",
"videos": [234324, 234322314, 23, 5, 435, 12, 3, 234, 34, 23324]
},
"length": 3
}
Cause
When we create copyOfMovieLists
using Object.create
with one argument, we create a new array with the same prototype but none of the properties or elements.
Proposed Solution To return a new array, let's start with an empty array and add the movie list and instant queue:
function(queue, movieListsMessage) {
- var copyOfMovieLists = Object.create(movieListsMessage.list);
+ var copyOfMovieLists = [].concat(movieListsMessage.list);
Edit: Caught my own error using push
vs concat()
.
When you run Exercise 37, the alert box does not show the expected movie list. There are 3 problems here:
Observable.prototype.forEach
is now returning a Promise. This is the same problem that's causing the console error in #160. I'd suggest we change the exercise to usedo
to traverse events.Not all of the functions for the Observable signature have been updated from v4 to v5 so we're getting a
TypeError
:These should be changed at https://github.com/ReactiveX/learnrx/blob/gh-pages/index.html#L4573-L4592
With both of those changes made, there's a TypeError thrown from the
"load"
event handler:We fake
addEventListener
with a call tosetTimeout
but we don't pass a fake event in at https://github.com/ReactiveX/learnrx/blob/gh-pages/index.html#L4603-L4608. This would be better off using something like: