[Falcor] Return the data from server
<!-- index.html -->
<html>
<head>
<!-- Do _not_ rely on this URL in production. Use only during development. -->
<script src="//netflix.github.io/falcor/build/falcor.browser.js"></script>
<script>
var model = new falcor.Model( {
source: new falcor.HttpDataSource( '/model.json' )
} ); // retrieve the "greeting" key from the root of the Virtual JSON resource
model.getValue( 'genreList[0].titles[0].name' )
.then( function ( json ) {
console.log( JSON.stringify( json, null, 3 ) );
} )
</script>
</head>
<body>
</body>
</html>
var falcorExpress = require( 'falcor-express' );
var falcor = require('falcor');
var express = require( 'express' );
var app = express(); var $ref = falcor.Model.ref;
var model = new falcor.Model({
cache: {
titleById: {
5221: {
name: "House of Cards",
rating: {$type: "atom", value: 5},
bookmark: {$type: "error", value: "Something went wrong."}
}
},
genreList: [
{
name: 'Recently Watched',
titles: [
$ref("titleById[5221]")
]
},
{
name: "New Releases",
titles: [
$ref("titleById[5221]")
]
}
]
}
}); app.use(express.static(__dirname + '/'));
app.use( '/model.json', falcorExpress.dataSourceRoute( function ( req, res ) {
return model.asDataSource();
} ) ); var server = app.listen(3131);
[Falcor] Return the data from server的更多相关文章
- [Angular 2] implements OnInit, OnDestory for fetching data from server
Link: https://angular.io/docs/js/latest/api/core/OnInit-interface.html, https://www.youtube.com/watc ...
- zookeeper提示Unable to read additional data from server sessionid 0x
配置zookeeper集群,一开始配置了两台机器server.1和server.2. 配置参数,在zoo.cfg中指定了整个zookeeper集群的server编号.地址和端口: server.1=1 ...
- ajax 通过return 返回data值
方法例如以下: 1. ajax 必须为同步 设置async:false 2. 定一个局部变量 把data赋值给局部变量 然后 return 局部变量就可以 示比例如以下 function getEmp ...
- convert return char from sql server 2008 r2 or below version to c#
C# string.Replace((char)13, ' ') //newline char; string.Replace((char)10, ' ') //return char;
- Retrieving data from a server
A system includes a server and a controller embedded in a device. Both the server and the embedded c ...
- Using View and Data API with Meteor
By Daniel Du I have been studying Meteor these days, and find that Meteor is really a mind-blowing f ...
- 基于Libevent的HTTP Server
简单的Http Server 使用Libevent内置的http相关接口,可以很容易的构建一个Http Server,一个简单的Http Server如下: #include <event2/e ...
- [转]Installing SharePoint 2013 on Windows Server 2012 R2
转自:http://www.avivroth.com/2013/07/09/installing-sharepoint-2013-on-windows-server-2012-r2-preview/ ...
- [CareerCup] 10.2 Data Structures for Large Social Network 大型社交网站的数据结构
10.2 How would you design the data structures for a very large social network like Facebook or Linke ...
随机推荐
- .NET中删除空白字符串的10大方法
介绍 我们有无数方法可用于删除字符串中的所有空白.大部分都能够在绝大多数的用例中很好工作,但在某些对时间敏感的应用程序中,是否采用最快的方法可能就会造成天壤之别. 如果你问空白是什么,那说起来还真是有 ...
- oracle中 connect by prior 递归算法 -- 理解
oracle中 connect by prior 递归算法 -- 理解 http://blog.163.com/xxciof/blog/static/7978132720095193113752/ ...
- hdu 2480 贪心+简单并查集
Steal the Treasure Time Limit: 10000/6000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Othe ...
- 2013中国大数据技术大会——BDTC2013
阿里飞天平台总架构师唐洪分享了飞天开放平台. 飞天平台特点:同时支持在线和离线应用:安全控制:分布式部署,监控和诊断:无单点故障,可用性99.9%:数据3副本,数据可靠性“10个9”. 阿里飞天平台总 ...
- javaScript的select元素和option的相关操作
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- Nginx源码研究三:Epoll在NGINX中的使用
Web服务器在面对高并发的情况下,网络的IO一般选择IO复用,像apache选择的Select/poll.Nginx在linux 2.6后选择Epoll做网路IO,提高了WEB服务的并发能力. 在本章 ...
- java获取当前时间
/////////////////获取时间方法一////////////////////////////// java.util.Date uDate=new java.util.Date(); Sy ...
- javascript使用正则表达式验证Email地址
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- Swift— Swift编码规范之命名规范-备
程序代码中到处都是自己定义的名字,取一个有样并且符合规范的名字非常重要. 命名方法很多,但是比较有名的,广泛接受命名法有: 匈牙利命名,一般只是命名变量,原则是:变量名=类型前缀+描述,如bFoo表示 ...
- SJA1000寄存器设置
在设置CAN控制器SJA1000的输出控制寄存器(OCR)时,由于电路图中只用到了TX0和RX0,所以只考虑OCTP0,OCTN0,OCPOL0.这里设置成了010.然后查了一下配置的表,如下所示: ...