【发布时间】:2018-01-29 13:29:51
【问题描述】:
从外部 Api 发送过来的 json 数据如何缓存到 Falcor-Model 中?另外,如果缓存中不存在数据,如何在Model中指定再次命中外部Api?
我的疑问在其中一个帖子中得到了部分回答: How does Falcor cache data in the server side?
所以现在我了解到 Falcor-Model 缓存仅在客户端有效,这很好。但是如果缓存中不存在数据,模型将如何工作?
var model = new falcor.Model({source: new falcor.HttpDataSource('http://localhost/rating.json') });
model.
get("rating").
then(function(response) {
document.getElementById('filmRating').innerText = JSON.stringify(response.json.rating,null, 4);
});
这里的响应是一个 json 对象,可以放入 Falcor-Model 缓存并全局存储在客户端。但是如果缓存中不存在数据,如何再次触发模型呢?
【问题讨论】:
标签: falcor falcor-router