Last active
April 25, 2016 10:57
-
-
Save designeng/f00de5e04f27773eaf5c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Router = require('falcor-router'); | |
var data = { | |
items: [ | |
{name: "Acura", href: "/acura/"}, | |
{name: "Nissan", href: "/nissan/"}, | |
{name: "Ford" , href: "/ford/"} | |
] | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var ItemsRouter = Router.createClass([ | |
{ | |
route: 'items.length', | |
get: () => { | |
return {path: ['items', 'length'], value: data.items.length} | |
} | |
} | |
]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Router = require('falcor-router'); | |
var Falcor = require('falcor'); | |
var $atom = Falcor.Model.atom; | |
var data = { | |
items: [ | |
{name: "Acura", href: "/acura/"}, | |
{name: "Nissan", href: "/nissan/"}, | |
{name: "Ford" , href: "/ford/"} | |
] | |
}; | |
var ItemsRouter = Router.createClass([ | |
{ | |
route: "items", | |
get: function() { | |
return {path:["items"], value: $atom(data.items)}; | |
} | |
} | |
]); | |
// and then in the client code: | |
model.getValue(['items']) | |
.then(response => console.log(response)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var ItemsRouter = Router.createClass([ | |
{ | |
route: 'items.all', | |
get: () => { | |
return {path: ['items', 'all'], value: data.items} | |
} | |
} | |
]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
ItemsRouter_wrong.js throws MaxRetryExceededError: "The allowed number of retries have been exceeded."