You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using the todo list samples from the docs, we have the route get handling for genrelist[{integers:indices}].titles[{integers:titleIndices}]from falcor-router-demo here:
return recommendationService.
getGenreList(this.userId).
then(function(genrelist) {
var pathValues = [];
pathSet.indices.forEach(function (index) {
var genre = genrelist[index];
// If we determine that there is no genre at the index, we must
// be specific and return that it is the genre that is not
// present and not the name of the genre.
if (genre == null) {
pathValues.push({
path: ['genrelist', index],
value: genre
});
} else {
pathSet.titleIndices.forEach(function(titleIndex) {
var titleID = genrelist[index].titles[titleIndex];
if (titleID == null) {
pathValues.push({ path: ["genrelist", index, "titles", titleIndex], value: titleID });
}
else {
pathValues.push({
path: ['genrelist', index, 'titles', titleIndex],
value: $ref(['titlesById', titleID])
});
}
});
}
});
return pathValues;
});
The issue arises from this loose equality and the eventual usage of titleID:
if (titleID == null) {
pathValues.push({ path: ["genrelist", index, "titles", titleIndex], value: titleID });
}
// null == null is true
// undefined == null is true
Unfortunately, on falcor-router v0.4.0, it seems that setting value to undefined will prevent the ref lookup, and return back empty data.
Instead this needs to be null.
For those following along with the tutorials, please advise that you will need to coalesce to null, or some other way to ensure that undefined does not make its way into your values!
var titleID = genrelist[index].titles[titleIndex] || null;
The documentation/tutorial does not match implementation anymore, although I can see why this change was made as it makes the value types more JSON-compliant.
The text was updated successfully, but these errors were encountered:
camsjams
changed the title
In v0.4.0+, values of type undefined issue where refs are not retrieved
In v0.4.0+, values of type undefined work differently
Nov 28, 2016
camsjams
changed the title
In v0.4.0+, values of type undefined work differently
In v0.4.0+, values of type undefined work differently - update documentation
Nov 28, 2016
Using the todo list samples from the docs, we have the route
get
handling forgenrelist[{integers:indices}].titles[{integers:titleIndices}]
from falcor-router-demo here:The issue arises from this loose equality and the eventual usage of
titleID
:Unfortunately, on falcor-router v0.4.0, it seems that setting
value
toundefined
will prevent the ref lookup, and return back empty data.Instead this needs to be
null
.For those following along with the tutorials, please advise that you will need to coalesce to
null
, or some other way to ensure thatundefined
does not make its way into your values!The documentation/tutorial does not match implementation anymore, although I can see why this change was made as it makes the value types more JSON-compliant.
The text was updated successfully, but these errors were encountered: