This release is a developer preview. We are looking for community help to track down and fix bugs. We are also looking for help integrating with existing MVC frameworks, as well as ports to other platforms.
falcor 0.1.16 - DO NOT USE
We inadvertenly published master as 0.1.16 on npm by mistake. As a result it has backwards incompatible changes compared to v0.1.15 (MIGRATION.md in master has details about the backwards incompabile changes in master).
We've published falcor v0.1.17 to rectify this.
Even though the semver defintion is looser for 0.x versions, we intend to honor the major version position, and bump 0.x to 1.x for backwards incompatible changes, even while in developer preview, so that the version can be used reliably by build systems.
If you're including falcor in your app, via npm and
require('falcor'), and you're building a browser bundle for your app with Webpack, you'll need to add an alias entry for the 'rx' module in your webpack config, to avoid this RxJS bug: 'https://github.com/Reactive-Extensions/RxJS/issues/832'. You may already have such an entry, if you're using RxJS already. An example is below:
moduleexports =resolve:alias:// Workaround , until it's fixed'rx$': <path to rx/dist/rxjs file >;
You can check out a working example server for a Netflix-like application here right now. Alternately you can go through this barebones tutorial in which we use the Falcor Router to create a Virtual JSON resource. In this tutorial we will use Falcor's express middleware to serve the Virtual JSON resource on an application server at the URL /model.json. We will also host a static web page on the same server which retrieves data from the Virtual JSON resource.
In this example we will use the falcor Router to build a Virtual JSON resource on an app server and host it at /model.json. The JSON resource will contain the following contents:
"greeting": "Hello World"
Normally Routers retrieve the data for their Virtual JSON resource from backend datastores or other web services on-demand. However in this simple tutorial the Router will simply return static data for a single key.
First we create a folder for our application server.
mkdir falcor-app-servercd falcor-app-servernpm init
Now we install the falcor Router.
npm install falcor-router --save
Then install express and falcor-express. Support for restify is also available, as is support for hapi via a third-party implementation.
npm install express --savenpm install falcor-express --save
Now we create an index.js file with the following contents:
// index.jsvar falcorExpress = ;var Router = ;var express = ;var app = ;app;// serve static files from current directoryapp;var server = app;
Now we run the server, which will listen on port 3000 for requests for /model.json.
Now that we've built a simple virtual JSON document with a single read-only key "greeting", we will create a test web page and retrieve this key from the server.
Now create an index.html file with the following contents:
<!-- index.html --><!-- Do _not_ rely on this URL in production. Use only during development. -->
Now visit http://localhost:3000/index.html and you should see the message retrieved from the server:
For detailed high-level documentation explaining the Model, the Router, and JSON Graph check out the Falcor website.
For API documentation, go here
For a working example of a Router, check out the falcor-router-demo.
For questions and discussion, use Stack Overflow.