How to use the infusion.demands function in infusion

To help you get started, we’ve selected a few infusion 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 GPII / universal / gpii / node_modules / gpiiFramework / dataSource.js View on Github external
model.rev = resp._rev;
                }
                originalSet.apply(null, [directModel, model, couchDBCallback]);
            });
        };
    };

    gpii.dataSource.preInit = function (that) {
        that.nickName = "dataSource"; // work around FLUID-4636
        // Only enable set if writable is true.
        if (that.options.writable) {
            that.options.invokers.set = "gpii.dataSource.set";
        }
    };

    fluid.demands("gpii.dataSource.get", "gpii.dataSource.URL", {
        funcName: "gpii.dataSource.URL.handle",
        args: [{
            urlResolver: "{urlResolver}",
            errback: "{errback}",
            modelParser: "{modelParser}"
        }, "{arguments}.0", "{arguments}.1"]
    });

    fluid.demands("gpii.dataSource.set", "gpii.dataSource.URL", {
        funcName: "gpii.dataSource.URL.handle",
        args: [{
            urlResolver: "{urlResolver}",
            errback: "{errback}",
            modelParser: "{modelParser}",
            writeMethod: "{dataSource}.options.writeMethod"
        }, "{arguments}.0", "{arguments}.2", "{arguments}.1"]
github GPII / universal / gpii / node_modules / gpiiFramework / server.js View on Github external
that.configureHandler = function () {
            that.configure();
        };
    };

    gpii.server.config.finalInit = function (that) {
        that.events.configure.fire();
    };

    gpii.server.config.configureCreateRequest = function (server, requests) {
        server.configure(function () {
            server.use(requests.create);
        });
    };

    fluid.demands("gpii.server.config.configure", "gpii.server.config.createRequest", {
        funcName: "gpii.server.config.configureCreateRequest",
        args: ["{gpii.server}.server", "{requests}"]
    });

    fluid.demands("bodyParser", "gpii.server", {
        funcName: "gpii.middleware.bodyParser"
    });

})();
github GPII / universal / gpii / node_modules / gpiiFramework / dataSource.js View on Github external
listeners: {
            onError: "{that}.handleError"
        },
        preInitFunction: "gpii.dataSource.errback.preInit",
        invokers: {
            handleError: "gpii.dataSource.errback.handleError"
        }
    });

    gpii.dataSource.errback.preInit = function (that) {
        that.handleError = function (data) {
            that.handleError(data);
        };
    };

    fluid.demands("gpii.dataSource.errback.handleError", "gpii.dataSource.errback", {
        args: [
            "{callbackWrapper}",
            "{requestProxy}",
            "{arguments}.0"
        ]
    });

    /*
        Fires "onError" event of requestsProxy - a lightweight wrapper for
        requests component.
        Arguments:
            * callbackWrapper - component that wraps a function in context of
            current http request.
            * requestProxy - a wrapper for requests component.
    */
    gpii.dataSource.errback.handleError = function (callbackWrapper, requestProxy, data) {
github GPII / universal / gpii / node_modules / gpiiFramework / source.js View on Github external
gpii.source.post = function (dataSource, req, res) {
        dataSource.set(req.directModel, req.body, gpii.source.makeCallback(res));
    };

    gpii.source.makeCallback = function (res) {
        return function (resp) {
            if (!resp || resp && resp.isError) {
                res.send(resp.message, 404);
                return;
            }
            res.send(resp, 200);
        };
    };

    fluid.demands("gpii.source.all", "gpii.source", {
        funcName: "gpii.source.all",
        args: ["{gpii.source}.options", "{arguments}.0", "{arguments}.1", "{arguments}.2"]
    });

    fluid.demands("gpii.source.get", "gpii.source", {
        funcName: "gpii.source.get",
        args: ["{dataSource}", "{arguments}.0", "{arguments}.1"]
    });

    fluid.demands("gpii.source.post", "gpii.source", {
        funcName: "gpii.source.post",
        args: ["{dataSource}", "{arguments}.0", "{arguments}.1"]
    });

})();
github GPII / universal / gpii / node_modules / gpiiFramework / dataSource.js View on Github external
preInitFunction: "gpii.dataSource.preInit"
    });

    /*
        Model parser component that does both parsing and stringification of json
        payloads for a dataSource.
    */
    fluid.defaults("gpii.dataSource.modelParser", {
        gradeNames: ["autoInit", "fluid.littleComponent"],
        invokers: {
            stringify: "gpii.dataSource.modelParser.stringify",
            parse: "gpii.dataSource.modelParser.parse"
        }
    });

    fluid.demands("gpii.dataSource.modelParser.parse", "gpii.dataSource.modelParser", {
        args: [{
            responseParser: "{dataSource}.options.responseParser",
            errback: "{errback}"
        }, "{arguments}.0"]
    });

    /*
        Parses the payload from the source of data.
        Arguments:
            * options {Object} - contains responseParses (a function or a name of a
            global function) that parses the raw response data; errback - a component
            whose "onError" event if fired if there's something wrong with the 
            payload (e.g. the returned data is an error).
            * data {Object|String} - raw data from the source.
    */
    gpii.dataSource.modelParser.parse = function (options, data) {
github GPII / universal / gpii / node_modules / gpiiFramework / middleware.js View on Github external
args: "{that}"
            }, {
                listener: "gpii.middleware.apply",
                args: ["{gpii.server}.server", "{that}.resolveEventName"]
            }]
        }
    });

    gpii.middleware.apply = function (server, resolveEventName) {
        server.use(function (req, res, next) {
            var eventName = resolveEventName();
            req.fluidRequest.events[eventName].fire(req.fluidRequest);
        });
    };

    fluid.demands("gpii.middleware.resolveEventName", null, {
        funcName: "gpii.middleware.resolveEventName",
        args: "{middleware}.typeName"
    });

    gpii.middleware.resolveEventName = function (typeName) {
        var eventName = fluid.computeNickName(typeName);
        return "on" + eventName.charAt(0).toUpperCase() + eventName.slice(1);
    };

    fluid.defaults("gpii.middleware.bodyParser", {
        gradeNames: ["gpii.middleware", "autoInit"],
        invokers: {
            handle: {
                funcName: "gpii.middleware.bodyParserHandle"
            }
        }
github GPII / universal / gpii / node_modules / gpiiFramework / request.js View on Github external
res.send(error, 500);
        };

        that.onSuccessHandler = function (response) {
            that.res.send(response, 200)
        };
    };

    fluid.defaults("gpii.requests.request.deferred", {
        gradeNames: ["autoInit", "fluid.eventedComponent"],
        invokers: {
            when: "gpii.requests.request.deferred.when"
        }
    });

    fluid.demands("gpii.requests.request.deferred.when", "gpii.requests.request.handler", {
        args: ["{requestProxy}", "{arguments}.0", "{arguments}.1"]
    });

    gpii.requests.request.deferred.when = function (evented, promiseOrValue, callback) {
        return when(promiseOrValue, function (resolved) {
            evented.events.onSuccess.fire(callback ? callback(resolved) : resolved);
        }, function (error) {
            evented.events.onError.fire(error);
        });
    };

    fluid.defaults("gpii.requests.request.handler", {
        gradeNames: ["gpii.requests.request.deferred", "autoInit"],
        invokers: {
            handle: {
                funcName: "gpii.requests.request.handler.handle"
github GPII / universal / gpii / node_modules / gpiiFramework / configLoader.js View on Github external
fluid.each(demands, function (demand) {
            fluid.demands(demand.demandingName, demand.contextNames, demand.demandSpec);
        });
        fluid.defaults(componentName, config.options);
github GPII / universal / gpii / node_modules / gpiiFramework / server.js View on Github external
gpii.server.config.finalInit = function (that) {
        that.events.configure.fire();
    };

    gpii.server.config.configureCreateRequest = function (server, requests) {
        server.configure(function () {
            server.use(requests.create);
        });
    };

    fluid.demands("gpii.server.config.configure", "gpii.server.config.createRequest", {
        funcName: "gpii.server.config.configureCreateRequest",
        args: ["{gpii.server}.server", "{requests}"]
    });

    fluid.demands("bodyParser", "gpii.server", {
        funcName: "gpii.middleware.bodyParser"
    });

})();
github GPII / universal / gpii / node_modules / gpiiFramework / request.js View on Github external
});

    gpii.requests.request.handler.finalInit = function (that) {
        fluid.withEnvironment({
            request: that.request
        }, that.handle);
    };

    fluid.defaults("gpii.requestContextCallbackWrapper", {
        gradeNames: ["autoInit", "fluid.littleComponent"],
        invokers: {
            wrap: "gpii.requestContextCallbackWrapper.wrap"
        }
    });

    fluid.demands("gpii.requestContextCallbackWrapper.wrap", "gpii.requestContextCallbackWrapper", {
        funcName: "gpii.wrapCallback",
        args: ["{arguments}.0", "{arguments}.1"]
    });

    gpii.wrapCallback = function (callback) {
        var request = fluid.resolveEnvironment("{request}", {
            fetcher: fluid.makeEnvironmentFetcher()
        });
        return function () {
            var args = arguments;
            fluid.withEnvironment({
                request: request
            }, function () {
                callback.apply(null, args);
            });
        };