Given some function specs we would like to know if there are bugs in a function definition associated with invalid function calls.
(s/fdef foo :args (s/cat :x number? :y number?) :ret string?)
(s/fdef bar :args (s/cat :z coll?) :ret number?)
Without a persistent data store our React Native app would lose all state if killed and restarted.
React Native solves this by providing a simple storage system that is global to the app called AsyncStorage.
It is recommended that you use an abstraction on top of AsyncStorage like sunnylqm/react-native-storage but for now a few helper functions seem to suffice. Here's an alternative approach.
Without a persistent data store our app would lose all state if killed and restarted.
React Native solves this by providing a simple storage system that is global to the app called AsyncStorage. It is recommended that you use an abstraction on top of AsyncStorage so we use sunnylqm/react-native-storage.
We've introduced a dependency here. It's possible working directly with StorageAsync would have sufficed. See alternative approach.
I was struggling to compose datomic queries neatly. In the end I googled and found a blogpost which proposed a sane solution.
My motivation was an API endpoint with optional filters. I'd like my query include additional filters based on the args present.
Anyway, here's how my code ended up looking...
And the article: http://grishaev.me/en/datomic-query
(ns olivergeorge.schema | |
"generate datomic schema from simple spec forms" | |
(:require [clojure.spec.alpha :as s])) | |
(s/def ::schema-type | |
(s/or :db.type/string #{'string?} | |
:db.type/long #{'int? 'pos-int? 'neg-int? 'nat-int?} | |
:db.type/boolean #{'boolean?} | |
:db.type/float #{'float?} | |
:db.type/double #{'double?} |
(ns can-i-spy.dbg | |
(:require [clojure.spec.alpha :as s])) | |
(defonce dbg-meta (atom {})) | |
#?(:cljs (defonce dbg-data (atom {}))) | |
(defmacro spy | |
[k] | |
(let [symbols (keys (:locals &env)) |
(ns can-i-stub.main | |
(:require [cljs.nodejs :as nodejs] | |
[cljs.spec.alpha :as s] | |
[clojure.spec.test.alpha :as stest])) | |
(nodejs/enable-util-print!) | |
(defn add2 [a b] 10.1) | |
(s/fdef add2 :args (s/cat :a int? :b int?) :ret int?) |
Couple of extracts from lein deps :tree
With
:dependencies [[com.taoensso/encore "2.92.0"]
[org.clojure/clojurescript "1.9.946"]]
[com.taoensso/encore "2.92.0"]