Skip to content

Instantly share code, notes, and snippets.

@Jannis
Jannis / gist:b4fc1c36a68e5bbef170
Last active Oct 30, 2015
Om Next mutation with validation (thin.ng/validate)
View gist:b4fc1c36a68e5bbef170
;;;; Parser
(def card-schema
{:id [(v/number) (v/pos)]
:assignees [(v/optional (v/vector))]
:text [(v/string) (v/min-length 1 "The description may not be empty")]})
(defn validate-card [card]
(assoc card :errors (second (v/validate card card-schema))))
View gist:307e03a461e9b7cc26e3
[jannis@columba om]$ git diff
diff --git a/project.clj b/project.clj
index e0b854f..3b39ce7 100644
--- a/project.clj
+++ b/project.clj
@@ -19,7 +19,7 @@
[devcards "0.2.0-8" :scope "provided"]
]
- :plugins [[lein-cljsbuild "1.1.0"]]
View gist:cfb533ed03d304e346e6
Uncaught #error {:message "No queries exist for component path (#object[Pv \"function Pv(){React.Component.apply(this,arguments);this.state=null!=this.la?this.la():{};return this}\"])", :data {:type :om.next/no-queries}}
@Jannis
Jannis / txbind.cljs
Last active Nov 10, 2015
Hack to bind Om Next transaction reads to a component
View txbind.cljs
;; Function to resolve keys passed to an Om Next transaction to their corresponding
;; queries in the component that triggered the transaction. Ugly as hell. ;)
;;
;; (defui Foo
;; static om/IQuery
;; (query [this]
;; [:app/foo
;; {:app/bar (om/get-query Bar)}
;; ({:app/baz (om/get-query Baz)} {:param "Value"})])
;;
View normalization.clj
;;;; Data
[{:name "r/ui",
:children [{:name "r/ui/green-button"} {:name "r/ui/red-button"}],
:kind "requirement",
:title "UI Requirements",
:description "A somewhat long description spread across multiple lines.\n",
:parent nil}
{:name "r/ui/green-button",
:children [],
View gist:eaaebe824f28f261be90
(ns om-tutorial.core
(:require [goog.dom :as gdom]
[om.next :as om :refer-macros [defui]]
[om.dom :as dom]))
(enable-console-print!)
;;;; Initial (denormalized) data
(def initial-state
View foo.clj
(ns om-tutorial.core
(:require [goog.dom :as gdom]
[om.next :as om :refer-macros [defui]]
[om.dom :as dom]))
(enable-console-print!)
;;;; Initial (denormalized) data
(def initial-state
View showdown-ext.cljs
(defn uml-extension [converter]
[{:type "lang"
:regex #"@startuml\s+(.*?)\s+@enduml"
:replace (fn [s match]
(println "S >>" s)
(println "M >>" match)
s)}])
(def converter
(js/Showdown.converter. {:extensions [uml-extension]}))
View gist:2c6ff92d7ff973fcfb44
Uncaught #error {:message "No queries exist for component path (#object[Mx \"function Mx(){React.Component.apply(this,arguments);this.state=null!=this.ga?this.ga():{};return this}\"] #object[Xv \"function Xv(){React.Component.apply(this,arguments);this.state=null!=this.ga?this.ga():{};return this}\"])", :data {:type :om.next/no-queries}}
us.j @ app.js:606
us.h @ app.js:605
ft @ app.js:633
h.Mf @ app.js:622
hp @ app.js:481
b @ app.js:591
View gist:99121e9a292b4770f416
Uncaught #error {:message "No queries exist for component path (#object[$web$app$App$$ \"function $web$app$App$$(){React.Component.apply(this,arguments);this.state=null!=this.$initLocalState$?this.$initLocalState$():{};return this}\"] #object[$web$components$requirements$Requirement$$ \"function $web$components$requirements$Requirement$$(){React.Component.apply(this,arguments);this.state=null!=this.$initLocalState$?this.$initLocalState$():{};return this}\"])", :data {:type :om.next/no-queries}}
$om$next$full_query$$.$cljs$core$IFn$_invoke$arity$2$ @ app.js:2308
$om$next$full_query$$.$cljs$core$IFn$_invoke$arity$1$ @ app.js:2305$om$next$default_ui__GT_props$$ @ app.js:2444
$JSCompiler_prototypeAlias$$.$om$next$protocols$IReconciler$reconcile_BANG_$arity$1$ @ app.js:2391
$om$next$protocols$reconcile_BANG_$$ @ app.js:1798$f$$359$$ @ app.js:2230