This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns navigation.example | |
(:require-macros [natal-shell.components :refer [navigator]] | |
[navigation.macros :refer [with-om-vars]]) | |
(:require [om.next :as om])) | |
;;; Helpers for getting a deep ref | |
(defn react-ref | |
"Wrapper around react-ref to always turn keywords into strings." | |
[component ref] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(declare fail) | |
(defn fail* [m] | |
(if (map? m) | |
(fail 1) | |
m)) | |
(defmacro fail [m] | |
(if (map? m) | |
(fail* m) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; This is a stand alone version of https://github.com/petterik/om/commit/c99f1b892f0a143fba6ce57c3ffefc7ce1e2b9a0 | |
;; Changed so that in path-meta, we're parsing the joins from a query one time for each data collection | |
;; instead of parsing joins for each item in the collection. | |
;; This gist contains implementation and a test. | |
;; It's runnable with planck by either downloading the gist as gist.cljs and passing it to planck | |
;; with the om source code: | |
;; planck -c "<path-to-om-project>/src/main" gist.cljs | |
(ns petterik.path-meta-perf |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/main/om/next.cljc b/src/main/om/next.cljc | |
index ff19d99..3ea9682 100644 | |
--- a/src/main/om/next.cljc | |
+++ b/src/main/om/next.cljc | |
@@ -2517,10 +2517,10 @@ | |
root (:root @state)] | |
#?(:cljs | |
(doseq [c ((:optimize config) cs)] | |
- (let [props-change? (> (p/basis-t this) (t c))] | |
+ (let [props-change? (and (iquery? c) (> (p/basis-t this) (t c)))] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; Here are 4 different versions of the sieve function with slight changes to test my theories | |
;; around seq, chunked-seq and transducer (reduce) api. | |
;; Try running these yourself with: (run-all) | |
(declare sieves) | |
(defn run-all [] | |
(doseq [[k sieve] sieves] | |
(prn "Running:" k) | |
(dotimes [_ 5] | |
(time (sieve 10000))))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(require '[datascript.btset :as btset]) | |
(require '[datascript.arrays :as da]) | |
;; What? | |
;; Fast equality check for btset/Iter | |
;; | |
;; Why? | |
;; There's no history or (d/since ) API and I want to know what's changed between two databases. | |
;; With fast Iter equality checks, I can quickly check if an attribute has changed between | |
;; my two database values like so: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn join [{:keys [parser query target] :as env} k _] | |
(let [ret (parser env query target)] | |
(if target | |
(when (seq ret) | |
{target (assoc ast :query ret)}) | |
{:value ret}))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defmacro with-defs | |
"Takes a seq of symbols which will be called with def for generated symbols. | |
These symbols will be replaced in the body with the generated symbols | |
Examples: | |
(let [a 1] (macroexpand '(with-defs [a] [a]))) ;; => (do (def a_60267 a) [a_60267]) | |
(let [a 1] (with-defs [a] [a])) ;; => [1]" | |
[vars & body] | |
{:pre [(every? symbol? vars)]} | |
(let [syms (into {} (map (juxt identity #(gensym (str (name %) "_")))) vars) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; Issue with om/transform-reads | |
;; Issue is when having two siblings or cousins with the same read-key | |
;; in nested at level 2 or deeper, transform-reads will two paths | |
;; with the same root. Parsing such query will overwrite the first path | |
;; returning only the second one. | |
;; Example: | |
;; (om/transform-reads r [:foo]) | |
;; returns: [#:join{:parent [#:join{:child1 [:foo]}]} | |
;; #:join{:parent [#:join{:child2 [:foo]}]}] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Did: | |
- Built optimizations :advanced, clojurescript 1.9.683 with cljs.loader | |
Happened: | |
- Compilation ran forever. Last output being: | |
`Compiling resources/public/release/js/out/cljs/loader.cljs` | |
Debug: | |
- Ran 5 times: | |
`jstack 54630 >> cljs-loader-compile.stack` |