falcor
Version:
A JavaScript library for efficient data fetching.
25 lines (22 loc) • 818 B
JavaScript
var pathSyntax = require("falcor-path-syntax");
var ModelResponse = require("./../ModelResponse");
var GET_VALID_INPUT = require("./validInput");
var validateInput = require("./../../support/validateInput");
var GetResponse = require("./GetResponse");
/**
* Performs a get on the cache and if there are missing paths
* then the request will be forwarded to the get request cycle.
* @private
*/
module.exports = function get() {
// Validates the input. If the input is not pathSets or strings then we
// will onError.
var out = validateInput(arguments, GET_VALID_INPUT, "get");
if (out !== true) {
return new ModelResponse(function(o) {
o.onError(out);
});
}
var paths = pathSyntax.fromPathsOrPathValues(arguments);
return new GetResponse(this, paths);
};