1. <!-- index.html -->
  2. <html>
  3. <head>
  4. <!-- Do _not_ rely on this URL in production. Use only during development. -->
  5. <script src="//netflix.github.io/falcor/build/falcor.browser.js"></script>
  6. <script>
  7. var model = new falcor.Model( {
  8. source: new falcor.HttpDataSource( '/model.json' )
  9. } );
  10.  
  11. // retrieve the "greeting" key from the root of the Virtual JSON resource
  12. model.getValue( 'genreList[0].titles[0].name' )
  13. .then( function ( json ) {
  14. console.log( JSON.stringify( json, null, 3 ) );
  15. } )
  16. </script>
  17. </head>
  18. <body>
  19. </body>
  20. </html>
  1. var falcorExpress = require( 'falcor-express' );
  2. var falcor = require('falcor');
  3. var express = require( 'express' );
  4. var app = express();
  5.  
  6. var $ref = falcor.Model.ref;
  7. var model = new falcor.Model({
  8. cache: {
  9. titleById: {
  10. 5221: {
  11. name: "House of Cards",
  12. rating: {$type: "atom", value: 5},
  13. bookmark: {$type: "error", value: "Something went wrong."}
  14. }
  15. },
  16. genreList: [
  17. {
  18. name: 'Recently Watched',
  19. titles: [
  20. $ref("titleById[5221]")
  21. ]
  22. },
  23. {
  24. name: "New Releases",
  25. titles: [
  26. $ref("titleById[5221]")
  27. ]
  28. }
  29. ]
  30. }
  31. });
  32.  
  33. app.use(express.static(__dirname + '/'));
  34. app.use( '/model.json', falcorExpress.dataSourceRoute( function ( req, res ) {
  35. return model.asDataSource();
  36. } ) );
  37.  
  38. var server = app.listen(3131);

[Falcor] Return the data from server的更多相关文章

  1. [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 ...

  2. zookeeper提示Unable to read additional data from server sessionid 0x

    配置zookeeper集群,一开始配置了两台机器server.1和server.2. 配置参数,在zoo.cfg中指定了整个zookeeper集群的server编号.地址和端口: server.1=1 ...

  3. ajax 通过return 返回data值

    方法例如以下: 1. ajax 必须为同步 设置async:false 2. 定一个局部变量 把data赋值给局部变量 然后 return 局部变量就可以 示比例如以下 function getEmp ...

  4. 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;

  5. Retrieving data from a server

    A system includes a server and a controller embedded in a device. Both the server and the embedded c ...

  6. 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 ...

  7. 基于Libevent的HTTP Server

    简单的Http Server 使用Libevent内置的http相关接口,可以很容易的构建一个Http Server,一个简单的Http Server如下: #include <event2/e ...

  8. [转]Installing SharePoint 2013 on Windows Server 2012 R2

    转自:http://www.avivroth.com/2013/07/09/installing-sharepoint-2013-on-windows-server-2012-r2-preview/ ...

  9. [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 ...

随机推荐

  1. 关于<%@ include file=" " %>与<jsp:include page=""></jsp:include>中的那些问题?

    今天在使用<%@ include file=" " %>指令时,竟然在页面中不让使用?这是怎么回事:问题如下图: 顿时被这个问题给搞到了!!!突然想到在以前的 JSP ...

  2. JAVA-1-HelloWorld

    public class HelloWorld{ public static void main(String[] args){ System.out.println("HelloWorld ...

  3. UVA 305 Joseph (约瑟夫环 打表)

     Joseph  The Joseph's problem is notoriously known. For those who are not familiar with the original ...

  4. 思科27亿美元收购网络安全公司Sourcefire

    据国外媒体报道,思科于今日宣布将以27亿美元的总价收购网络安全公司Sourcefire,以加强自身在网络安全业务领域的优势,该交易将于今年下半年完成. [IT商业新闻网讯](记者 张良)7月23日消息 ...

  5. span里设置高度

    众所周知,SPAN元素内单纯设置height是没有效果的. 需要设置SPAN的高度,需要将其设置成block元素. display:block 但这样会导致span占据了整一行,我们通常不希望这样. ...

  6. phpcms v9二次开发之模型类的应用(2)

    二.模型操作方法select()--查询语句         //查询级别管理列表信息    public function levellists() { $lelists = $this->l ...

  7. 字符串匹配算法之Sunday算法

    字符串匹配查找算法中,最着名的两个是KMP算法(Knuth-Morris-Pratt)和BM算法(Boyer-Moore).两个算法在最坏情况下均具有线性的查找时间.但是在实用上,KMP算法并不比最简 ...

  8. vim编辑器中撤销和恢复操作

    在VIM编辑器下切换至命令行模式: 撤销: u 恢复: ctrl + r

  9. 第几天 switch做法 杭电

    第几天? Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submi ...

  10. 转:1.1 cdev_init cdev_alloc 使用说明

    对 “从globalmem学习linux字符设备驱动” 的 cdev_init 和 cdev_alloc中一些不清楚的地方进行说明:   cdev_init 和 cdev_alloc函数定义如下:   ...