How to use the falcor.Model.ref function in falcor

To help you get started, we’ve selected a few falcor examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github KillrVideo / killrvideo-web / build / build-sample-data.js View on Github external
var gulp = require('gulp');
var fs = require('fs');
var path = require('path');
var _ = require('lodash');
var moment = require('moment');
var EOL = require('os').EOL;
var falcorModel = require('falcor').Model;
var $ref = falcorModel.ref;
var $atom = falcorModel.atom;

// Some constants
var OUTPUT_FILE_NAME = 'sample-data-cache.js';
var OUTPUT_FOLDER = './src/js/stores';

// Sample data JSON
var videos = require('../data/videos.json');
var users = require('../data/users.json');
var comments = require('../data/comments.json');

// Helper function for generating an int from part of a UUID
function getIntFromPartOfUuid(uuid, startIdx, numChars, maxValue) {
  var hex = uuid.substr(startIdx, numChars);
  return parseInt('0x' + hex) % maxValue;
}
github Netflix / falcor-router / test / unit / internal / jsongMerge.spec.js View on Github external
var jsongMerge = require('./../../../src/cache/jsongMerge');
var Model = require('falcor').Model;
var $ref = Model.ref;
var $atom = Model.atom;
var expect = require('chai').expect;
var _ = require('lodash');

/**
 * normally i don't test internals but i think the merges
 * warrent internal testing.  The reason being is that the
 * merges are core to the product.  If i don't, i will have to
 * figure out where bugs are without much clarity into where they
 * are.
 */
describe('JSONG - Merge', function() {

    it('should write a simple path to the cache.', function() {

        var jsong = {
github graphistry / falcor / test / unit / internal / optimizePathSets.spec.js View on Github external
var optimizePathSets = require('./../../../src/cache/optimizePathSets');
var Model = require('falcor').Model;
var $ref = Model.ref;
var $atom = Model.atom;
var expect = require('chai').expect;
var errors = require('./../../../src/exceptions');

/**
 * normally i don't test internals but i think the merges
 * warrent internal testing.  The reason being is that the
 * merges are core to the product.  If i don't, i will have to
 * figure out where bugs are without much clarity into where they
 * are.
 */
describe('optimizePathSets', function() {
    it('should optimize simple path.', function() {
        var cache = getCache();
        var paths = [['videosList', 3, 'summary']];
github graphistry / falcor / test / unit / internal / jsongMerge.spec.js View on Github external
var jsongMerge = require('./../../../src/cache/jsongMerge');
var Model = require('falcor').Model;
var $ref = Model.ref;
var $atom = Model.atom;
var expect = require('chai').expect;
var _ = require('lodash');

/**
 * normally i don't test internals but i think the merges
 * warrent internal testing.  The reason being is that the
 * merges are core to the product.  If i don't, i will have to
 * figure out where bugs are without much clarity into where they
 * are.
 */
describe('JSONG - Merge', function() {

    it('should write a simple path to the cache.', function() {

        var jsong = {
github tivac / falcor-experiment / router / account / dyes.js View on Github external
"use strict";

var Model = require("falcor").Model,
    $ref  = Model.ref,
    $atom = Model.atom,
    
    http = require("../../lib/http"),
    auth = require("./lib/auth");

module.exports = [ {
    route : "account.dyes.length",
    get   : auth(function(key, pathset) {
        return http.json("https://api.guildwars2.com/v2/account/dyes?access_token=" + key).then(function(resp) {
            return {
                path  : pathset,
                value : $atom(resp.length)
            };
        });
    })
}, {
github tivac / falcor-experiment / router / colors.js View on Github external
"use strict";

var Model  = require("falcor").Model,
    $ref   = Model.ref,
    $atom  = Model.atom,
    $error = Model.atom,
    
    http   = require("../lib/http"),
    map    = require("./lib/map-ids"),
    fields = require("./lib/fields");

module.exports = [ {
    route : "colors.length",
    get   : function(pathset) {
        return http.json("https://api.guildwars2.com/v2/colors")
            .then(function(json) {
                return {
                    path  : pathset,
                    value : $atom(json.length)
                };
github tivac / falcor-experiment / router / colorsById.js View on Github external
"use strict";

var Model  = require("falcor").Model,
    $error = Model.error,
    $atom  = Model.atom,
    $ref   = Model.ref,
    
    chunk  = require("./lib/chunk"),
    map    = require("./lib/map-ids"),
    fields = require("./lib/fields");

module.exports = [ {
    route : "colorsById[{integers:ids}].id",
    get   : function(pathset) {
        return pathset.ids.map(function(id) {
            return {
                path  : [ pathset[0], id, pathset[2] ],
                value : $atom(id)
            };
        });
    },
}, {