[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 ...
随机推荐
- yii2 添加模块过程
本文以Yii2基本应用程序模板为例,介绍下向该框架下加入新模块的过程: 1. 新建模块相关目录与文件 step 1: 新建目录结构 首先在根目录下新建modules目录,然后在该目录下面添加模块目 ...
- 如何使用CSS Sprites技术进行图片合并
http://jingyan.baidu.com/article/066074d6757654c3c21cb02d.html
- 如何安装Git到MAC OS X
这里介绍两种方式:一,使用Git command-line二,使用GUI工具SourceTree,功能很强大,很方便 在进行安装前,要说一下,Git和SVN一样,都需要创建一个服务器的,他们都可以创建 ...
- jQuery旋转插件
jQuery旋转插件,支持Internet Explorer 6.0 + .Firefox 2.0.Safari 3.Opera 9.Google Chrome,高级浏览器下使用Transform,低 ...
- 使用poi3.9的jar输出excel
// 取得模板文件存放的路径 ReadFilePath = ServletActionContext.getServletContext().getRealPath(ExcelTemplateFile ...
- 《Linux内核分析》 week8作业-Linux加载和启动一个可执行程序
一.ELF文件格式 ELF(Executable and Linking Format)是x86 Linux系统下常用的目标文件格式,有三种主要类型: 适于连接的可重定位文件,可与其他目标文件一起创建 ...
- jquery获取浏览器高度、宽度和滚动条高度(来自网络)
Jquery代码: alert($(window).height()); //浏览器时下窗口可视区域高度 alert($(document).height()); //浏览器时下窗口文档的高度 ale ...
- trident教程
(一)理论基础更多理论以后再补充,或者参考书籍1.trident是什么?Trident is a high-level abstraction for doing realtime computi ...
- input 类型为number型时,maxlength不生效?
input 类型为number型时,maxlength不生效? 可以加oninput属性来控制最大长度:<input id="numInput" type="num ...
- PHPCMSV9 采集网址后,再采集内容,报错:“采集采集内容 没有找到网址列表,请先进行网址采集”
解决方法:直接清除v9_collection_history 表里的内容.