falcor 介绍
Falcor 是高效的 JavaScript 数据抓取库。?
一个 模型随处使用 :通过 一个 虚拟 jsON 图可以把所有远程数据源作为 一个 单独的主模型
数据即是 API :类似 JavaScript 路径语法,可以很简单的访问数据。
绑定云 : 自动 遍历图里面的引用,根据需要进行请求
falcor安装
npm install falcor-router --save
然后安装Express和Falcor Express:
npm install express --save
npm install falcor-express --save
? 代码 示例:
// index.js
const falcorExpress = require('falcor-express');
const Router = require('falcor-router');
const express = require('express');
const app = express();
app.use('/model.json',falcorExpress.dataSourceRoute(function (req,res) {
// create a Virtual jsON resource with single key ('greeting')
return new Router([
{
// match a request for the key 'greeting'
route: 'greeting',
// respond with a PathValue with the value of 'Hello World.'
get: () => ({path: ['greeting'],value: 'Hello World'})
}
]);
}));
// serve static files from current directory
app.use(express.static(__dirname + '/'));
app.listen(3000);
网站地址 : http://netflix.github.io/falcor
GitHub: https://github.com/Netflix/falcor
网站描述: 一个 高效的 JavaScript 数据抓取库
falcor官方网站
官方网站: http://netflix.github.io/falcor
如果觉得 网站内容还不错,欢迎将 网站 推荐给程序员好友。