This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-07-12
Channels
- # aleph (1)
- # beginners (81)
- # boot (20)
- # cider (46)
- # cljs-dev (6)
- # cljsjs (6)
- # cljsrn (8)
- # clojars (2)
- # clojure (104)
- # clojure-berlin (3)
- # clojure-italy (4)
- # clojure-losangeles (2)
- # clojure-nl (16)
- # clojure-spec (16)
- # clojure-uk (28)
- # clojurescript (88)
- # core-logic (31)
- # cursive (8)
- # data-science (3)
- # datascript (1)
- # datomic (95)
- # docs (1)
- # emacs (6)
- # figwheel-main (24)
- # fulcro (106)
- # graphql (5)
- # hyperfiddle (2)
- # midje (2)
- # nrepl (1)
- # off-topic (14)
- # om-next (1)
- # parinfer (2)
- # pedestal (26)
- # portkey (2)
- # re-frame (11)
- # reagent (27)
- # ring (6)
- # rum (4)
- # shadow-cljs (33)
- # spacemacs (10)
- # specter (53)
- # tools-deps (17)
- # vim (31)
Hi! How is better to wrap a component with data fetcher in re-frame?
(defn with-fetch-table []
(let [cached-filters (reagent/atom nil)
cached-offset (reagent/atom nil)
this (reagent/current-component)
query-debounce (debounce re-frame/dispatch 1000)]
(fn [{:keys [offset]
:as props}]
(let [filters
(select-keys props [:filter-1 :filter-2])
query-fn #(query-debounce
[:graphql/query
{:operation-name "backoffice-fetch"
:refetch-on #{:table-row-remove} ;; re-frame-forward-events-fx
:query (query/fetch-table
(merge filters
{:offset @offset}))}])]
(when-not (= @cached-offset @offset)
(reset! cached-offset @offset)
(query-fn))
(when-not (= @cached-filters filters)
(reset! cached-filters filters)
(reset! cached-offset 0)
(reset! offset 0)
(query-fn))
(reagent/children this)))))
I use forward-fx for events that trigger re-fetching but I don't know how do to it for filters and pagination as in my example above. They are stored in simple ratom on the page, because I need them in local state only. Any best practices for such cases?@ferossgp If I understand you issue correctly, there have been brief discussions about similar concerns in the past. It seems that mixing purely re-frame
components (subscriptions for "data in", dispatches for "data out") with reagent/atom
doesn't really work if you need the data from the ratoms somewhere else.
i’m doing the walkthrough https://github.com/Day8/re-frame/blob/master/docs/CodeWalkthrough.md. I want to get cider through emacs to connect to a repl so i can eval the clojure in emacs. Normally i would do ‘cider-jack-in’ to have cider start a repl and connect to it. In this case, i’m i supposed to connect to a repl that figwheel is starting?
I ask because any combination of cider-jack-in
or cider-jack-in-clojurescript
i try doesn’t seem to result in a working repl (I cant eval the cljs in emacs).
What's your cider-version
? 0.18.0-SNAPSHOT is undergoing heavy churn at the moment which is potentially related.
@drewverlee I don't have an answer to your question, but the question should probably be asked in #cider, #emacs, or in #clojurescript.
good point
@drewverlee lein new re-frame +cider
gives you a functional starting point where you can just cider-jack-in-clojurescript
and cider will launch a figwheel repl for you (along with clj repl). Check also this https://github.com/Day8/re-frame-template#start-cider-from-emacs-if-using-cider
It’s also possible to start figwheel repl outside emacs and make cider connect to it but it might be simpler to use cider-jack-in-clojurescript
.
Ah gotcha, so I should connect to the repl that figwheel started
Can anyone point me to an example of a master/detail view with re-frame + bidi/pushy?
I am using goog.History
instead of pushy:
- https://github.com/nenadalm/Warehouse/blob/d29bd308d5cf6697bd22cb138d26e5b271b3a2fe/frontend/src/warehouse/views.cljs#L19
- https://github.com/nenadalm/Warehouse/blob/d29bd308d5cf6697bd22cb138d26e5b271b3a2fe/frontend/src/warehouse/events.cljs#L46
- https://github.com/nenadalm/Warehouse/blob/d29bd308d5cf6697bd22cb138d26e5b271b3a2fe/frontend/src/warehouse/routes.cljs#L25