A simple faclor.js example.
This example uses handlebars and some falcor magic to list JS books.
Do check the demo!
Heart of the Server:
app.use('/library.json', falcorExpress.dataSourceRoute(function (req, res) {
return new Router([
{
route: "books.list",
get: function() {
return {path:["books"], value: JSON.stringify(Library) };
}
},
{
route: "books.names",
get: function() {
return {path:["books","names"], value: Library.map( book => book.name )};
}
}
]);
}));
Heart of the client:
var model = new falcor.Model({source: new falcor.HttpDataSource('/books.json') });
model.
get("books").
then(function(response) {
var books = JSON.parse(response.json.books);
});
MIT © Hemanth.HM