Skip to content

Instantly share code, notes, and snippets.

@noprompt
noprompt / mdiff.clj
Last active August 29, 2015 14:04
Map diff based on clj-diff.
(require '[clj-diff.core :as d])
(require '[clojure.set :as set])
(defn mdiff [ma mb base-path]
(let [es (reduce
(fn [m k]
(let [vb (get mb k)
kp (conj base-path k)]
(if-let [va (get ma k)]
(if (not= va vb)
(require '[clojure.core.async :as a])
(def xform (comp (map inc)
(filter even?)
(dedupe)
(flatmap range)
(partition-all 3)
(partition-by #(< (apply + %) 7))
(flatmap flatten)
(random-sample 1.0)
@robert-stuttaford
robert-stuttaford / start.cljs
Created August 21, 2014 13:07
Nicely grouped transaction logging in JS Console for Om apps
(ns app
(:require [om.core :as om :include-macros true]))
(defn log-tx [tx-data root-cursor]
(let [{:keys [path old-value new-value]} tx-data
c js/console]
(doto c (.group (str "TRANSACTION " path)) (.groupCollapsed "OLD"))
(prn (pr-str old-value))
(doto c (.groupEnd) (.group "NEW"))
(prn (pr-str new-value))
var Dialog = React.createClass({
render: function() {
// 1) render nothing, this way the DOM diff will never try to do
// anything to it again, and we get a node to mess with
return React.DOM.div();
},
componentDidMount: function() {
// 2) do DOM lib stuff
this.node = this.getDOMNode();
@borkdude
borkdude / tooltip-om.clj
Last active August 29, 2015 14:06
Add tooltip to Om DOM components showing displayname and contents of cursor and local state
;;; To add a tooltip, write (tooltip {:className "foo"}) instead of #js {:className "foo"}
;;; You can simplify this and just show what you need: #js {:title (pr-str (om/...))}.
;;; testfoo.core (cljs)
(ns testfoo.core
(:require-macros [testfoo.macros :refer (tooltip)])
(:require [om.core :as om :include-macros true]
[om.dom :as dom :include-macros true]
[cljs.reader :as reader]))

2015-01-29 Unofficial Relay FAQ

Compilation of questions and answers about Relay from React.js Conf.

Disclaimer: I work on Relay at Facebook. Relay is a complex system on which we're iterating aggressively. I'll do my best here to provide accurate, useful answers, but the details are subject to change. I may also be wrong. Feedback and additional questions are welcome.

What is Relay?

Relay is a new framework from Facebook that provides data-fetching functionality for React applications. It was announced at React.js Conf (January 2015).