@graphistry/falcor
Version:
A JavaScript library for efficient data fetching.
34 lines (32 loc) • 1.24 kB
JavaScript
var Observable = require('rx').Observable;
var R = require('@graphistry/falcor-router');
var Cache = require('./../Cache');
module.exports = function() {
return {
Integers: {
Summary: [{
route: ['videos', R.integers, 'summary'],
get: function (pathSet) {
return Observable.
from(pathSet[1]).
flatMap(function (id) {
var video = {};
var cacheVideo = Cache().videos[id];
if (cacheVideo) {
var jsong = {
jsonGraph: { videos: video },
paths: [
['videos', id, 'summary']
]
};
video[id] = {};
video[id].summary = cacheVideo.summary;
return Observable.return(jsong);
}
return Observable.empty();
});
}
}]
}
}
};