Skip to content

Instantly share code, notes, and snippets.

Wilker Lúcio wilkerlucio

View GitHub Profile
@wilkerlucio
wilkerlucio / pathom-persistent-cache.clj
Last active Mar 3, 2020
Pathom cache extension example
View pathom-persistent-cache.clj
(defn cache-resolver [resolver]
(update resolver ::pc/resolve
(fn [resolve]
(fn [{::keys [persistent-cache*] :as env} input]
(let [cache-key [(::pc/sym resolver) input (p/params env)]]
(if-let [[_ v] (find @persistent-cache* cache-key)]
v
(let [response (resolve env input)]
(swap! persistent-cache* assoc cache-key response)
response)))))))
@wilkerlucio
wilkerlucio / check-component.cljs
Created Nov 2, 2018
Generative testing for fulcro components
View check-component.cljs
(ns your-ns
(:require [clojure.test.check.properties :as prop]
[com.wsscode.pathom.gen :as sgen]
[cljs.test :refer [is]]
[clojure.test.check.generators :as gen :include-macros true]
[fulcro.client.primitives :as fp]
[clojure.test.check :as tc]
[fulcro.client.mutations :as fm]
[clojure.data :as data]))
View tether-js.js
/*! tether 1.4.4 */
(function(root, factory) {
if (typeof define === 'function' && define.amd) {
define([], factory);
} else if (typeof exports === 'object') {
module.exports = factory();
} else {
root.Tether = factory();
}
View trace-out.edn
[{:com.wsscode.pathom.trace/event
:com.wsscode.pathom.parser/parse-loop,
:com.wsscode.pathom.trace/timestamp-leave 1535741953047,
:com.wsscode.pathom.trace/timestamp 1535741952740,
:com.wsscode.pathom.core/path [],
:com.wsscode.pathom.trace/relative-timestamp 0,
:com.wsscode.pathom.trace/duration 307}
{:key :fulcro.inspect.workspaces.ui.pathom-trace-cards/color,
:com.wsscode.pathom.trace/event
:com.wsscode.pathom.parser/process-key,
View queued-video.cljs
(om/defui ^:once QueuedVideo
static uc/InitialAppState
(initial-state [_ title] {::video/id (random-uuid)
::video/title title})
static om/IQuery
(query [_] [::video/id
::video/watched?
{::video/snippet
[::video/title
View queued-video.cljs
(om/defui ^:once QueuedVideo
static uc/InitialAppState
(initial-state [_ title] {::video/id (random-uuid)
::video/title title})
static om/IQuery
(query [_] [::video/id
::video/watched?
{::video/snippet
[::video/title
View chrome-background-rpc.cljs
(ns ygq.background.main
(:require-macros [cljs.core.async.macros :refer [go]])
(:require [cljs.core.async :as async :refer [<!]]
[chrome.rpc :as rpc]
[ygq.background.parser :as p]
[google.api :as g]))
(defonce comm-listener
(go
(let [rpc (rpc/listen (async/chan 10))
View untangled-chrome-network.cljs
(ns ygq.popup.core
(:require-macros [cljs.core.async.macros :refer [go]])
(:require [untangled.client.core :as uc]
[cljs.core.async :as async :refer [<!]]
[chrome.rpc :as rpc]
[google.api :refer [get-auth-token]]
[untangled.client.network :as un]))
(defrecord Network [complete-app]
un/NetworkBehavior
View spec-coerce.clj
(ns common-spec.coerce
(:refer-clojure :exclude [def])
(:require [clojure.spec.alpha :as s]
[clojure.walk :as walk])
(:import (java.util UUID)))
(s/def ::coerce-fn
(s/fspec :args (s/cat :x string?) :ret any?))
(defonce ^:private registry-ref (atom {}))
@wilkerlucio
wilkerlucio / specter-walk-keys.clj
Last active Jun 2, 2017
Specter - walk map keys
View specter-walk-keys.clj
(def data
{:person/name "Bla"
:person/child {:child/something "other"
:child/bla {:subchild/entry "blabla"}}})
(def MapWalker
(sp/recursive-path [] p
(sp/if-path map?
(sp/continue-then-stay sp/MAP-VALS p))))
You can’t perform that action at this time.