【发布时间】:2016-07-29 16:19:00
【问题描述】:
我对这个模态层库 --- Falcor 非常感兴趣。而且我看了Falcor的官方文档,在JSON Graph section,一个The Abstract JSON Graph Operations的话题,说到call操作,我完全糊涂了。这是我根据官方示例的代码:
var jsonGraphObject = {
todosById: {
"44": {
name: "get milk from corner store",
addedAt: 29689724399,
done: false,
prerequisites: [{ $type: "ref", value: ["todosById", 54] }]
},
"54": {
name: "withdraw money from ATM",
addedAt: 15687384689,
done: false,
prerequisites: []
}
},
todos: [
{ $type: "ref", value: ["todosById", 44] },
{ $type: "ref", value: ["todosById", 54] }
]
};
var model = new falcor.Model({
cache: jsonGraphObject
});
然后文档向我展示了如何使用call:
model.call(
// callPath
["todos", "add"],
// arguments
["pick up car from the shop"],
// refPaths
[
["addedAt"]
],
// thisPaths
[
["length"]
])
.then(console.log.bind(console))
文档只是显示结果,但我的代码不起作用,我完全不知道这个add 函数在哪里,也不知道如何在 Falcor 的 JSON Graph 中定义函数。
我用谷歌搜索了它,但没有得到我的答案。那么那里有任何示例或样板项目吗?谢谢。
【问题讨论】:
标签: falcor