Skip to content

Instantly share code, notes, and snippets.

(fn [chain]
(fn [req]
(do-something-before req)
(chain req) ; continue the chain -- you could potentially not call this to interrupt the chain
(do-something-after req)))
function(chain) {
return function(req) {
doSomethingBefore(req);
chain(req);
doSomethingAfter(req);
};
}
can.Model({
findAll: function(params) {
var dfd = new can.Deferred();
$.get("/abc", params, function(response) {
dfd.resolve(response.model);
});
return dfd.promise();
}
(ns sample (:require [clojure.data.xml :as data.xml] [clojure.java.io :as io]))
(defn get-contact-info
"Extract info from tag"
[content tag]
(-> (filter #(= tag (:tag %)) content) first :content first))
(defn process-contact
"I don't do a whole lot."
[contact]
define({
$plugins: [
{ module: "wire/dom" },
{ module: "wire/on" }
],
model: { module: "app/model" },
getMenuOptions: { module: "app/get-menu-options" },
mealSelect: { $ref: "dom!meal-select" },
menuSelect: { $ref: "dom!menu-select" },
define({
$plugins: [
{ module: "wire/dom" },
{ module: "wire/on" }
],
model: { module: "app/model" },
getMenuOptions: { module: "app/get-menu-options" },
mealSelect: { $ref: "dom!meal-select" },
menuSelect: { $ref: "dom!menu-select" },
{
"name": "rave-wire-example",
"version": "0.0.0",
"description": "wire example",
"main": "app/run.js",
"authors": [
"foxdonut <fdaoud@proinbox.com>"
],
"moduleType": [
"amd"
@foxdonut
foxdonut / main.js
Created March 30, 2015 14:06
wire with require and extend
var _ = require("lodash");
module.exports = _.extend({
$plugins: [
require("wire/aop"),
require("msgs/wire"),
require("rest/wire")/*,
require("wire/debug")*/
]},
@foxdonut
foxdonut / wire-spec.js
Created March 30, 2015 14:08
wire with require and extend, some wire/aop
var _ = require("lodash");
module.exports = _.extend({
$plugins: [
require("wire/aop")
]},
require("../resource/wire-spec"), {
bookListViewModel: {
@foxdonut
foxdonut / client.js
Created March 30, 2015 14:37
more wire code
module.exports = function() {
var browser = require("rest/browser");
var mime = require("rest/interceptor/mime");
var client = browser.wrap(mime, { mime: "application/json" });
return client;
};