This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-08-27
Channels
- # announcements (10)
- # bangalore-clj (1)
- # beginners (130)
- # calva (8)
- # cider (66)
- # circleci (2)
- # clojure (197)
- # clojure-europe (2)
- # clojure-italy (8)
- # clojure-nl (5)
- # clojure-spec (14)
- # clojure-uk (35)
- # clojurescript (46)
- # code-reviews (5)
- # cursive (4)
- # datomic (88)
- # duct (1)
- # emacs (2)
- # figwheel-main (15)
- # fulcro (20)
- # graalvm (1)
- # graphql (3)
- # jackdaw (2)
- # leiningen (2)
- # off-topic (64)
- # pathom (53)
- # re-frame (52)
- # reagent (12)
- # reitit (43)
- # rewrite-clj (1)
- # shadow-cljs (38)
- # spacemacs (3)
- # sql (17)
- # tools-deps (6)
- # vim (30)
Guys, I want to keep my User Configurations up-to-date with Local Storage
.
(def set-user-interceptor [(path [:user :internal])
(after (partial set-item-ls conduit-user-key)) ;; write user to localstore (after)
trim-v])
does anybody here use re-frame without subscriptions? Wondering how significant the performance penalty is. As I understand it components don't rerender when their input subscriptions don't change.
Have you guys ever tried this ?
https://github.com/Day8/re-frame-10x
My configuration is valid but, it insistently spits repeated file to Google Closure
dependencies.
:dev-front {:source-paths ["src_front" "src_front_profile/desktopnew_front/dev"]
:incremental true
:jar true
:assert true
:compiler {:output-to "app/dev/js/front.js"
:externs ["app/dev/js/externs_front.js"]
:warnings true
:elide-asserts true
:npm-deps false
;; :target :nodejs
:closure-defines {"re_frame.trace.trace_enabled_QMARK_" true}
:preloads [day8.re-frame-10x.preload]
:main "desktopnew-front.core"
;; no optimize compile (dev)
:optimizations :none
:output-dir "app/dev/js/out_front"
;; simple compile (dev)
;;:optimizations :simple
;; advanced compile (prod)
;;:optimizations :advanced
;; :source-map "app/dev/js/test.js.map"
:pretty-print true
:output-wrapper true}}
It spits:
document.write('<script src="app/dev/js/out_front/goog/deps.js"></script>');
document.write('<script src="app/dev/js/out_front/cljs_deps.js"></script>');
But the valid path is /js/out_front/goog/….
It adds the repeated app/dev/
part to it.I'm handling a ::form-submitted
reg-event-fx. I need the current user. Right now it has (let [user @(rf/subscribe [:state/user])
Is this fine? Should I make an interceptor or coeffect that provides the user? Or is there some other strategy that I should be using?
i suppose i could have the event trigger pass it in but just seeing if there's another way
also this is probably a bit pervasive so want to know if this is a spend a friday and fix it totally, clean up as you go boyscout style, or totally fine
It's not an intended behavior, I couldn't remember the place where a situation like this is described. I think the best way is to add a coeffect.
is there a prebuilt coeffect for a subscription? or will the coeffect be (assoc cofx :user @(rf/subscribe [:state/user]))
essentially?
https://github.com/Day8/re-frame/blob/master/docs/FAQs/UseASubscriptionInAnEventHandler.md
How do you guys deal with re-frame apps that need to have bookmarks? I mean i want to have list of items and when i click on item - url changes so i can send ulr to a friend and he will see the same i am considering of using kee-frame but i imagine there has to be a way to do this with re-frame do you have any examples?
https://github.com/SMX-LTD/re-frame-cookie-fx the 2017 last commit doesn't bring confidence
@lepistane You'll probaly need a backend, which have an API that allows to save and retrieve data, and some kind of persistent storage, where the data is stored. Then you'll need a frontend router which will have routes for a list of items and for an item. And of course you'll need some kind of app that will handle loading and saving the data. These days it's often a SPA with some API backend, in the past it was often just a server-side app that served the HTML. Basically, an app like this don't have a requirement for a complex frontend part at all. So, any example with some kind of backend with persistent storage, and afrontend router will match if you want SPA.
@deadghost It's ok for clojure libs though. And fx for cookies is pretty simple I guess.
@jahson
backend is fine
i was interested in re-frame way of doing things
in router i'd want url/page/abc
and on load of that page to dispatch request to backend for page
with id=abc
i guess the example would be this https://github.com/Day8/re-frame/blob/master/examples/todomvc/src/todomvc/core.cljs#L34
Yeah, you might go this way. Or you could use any other router. On route match you'll dispatch an event and in event handler you'll fire the request to load the data.
You can use this https://github.com/jacekschae/conduit/blob/master/src/conduit/router.cljs
The :set-active-page
will be dispatched on route match
https://github.com/jacekschae/conduit/blob/master/src/conduit/router.cljs#L30-L33
For example, the home page https://github.com/jacekschae/conduit/blob/master/src/conduit/events.cljs#L81-L85
We see the :dispatch-n
here, it's a builtin effect
https://github.com/Day8/re-frame/blob/97a5c3795820cd37a976b62e2ac3cb1f626d2467/src/re_frame/fx.cljc#L120-L138
Let's look on :get-articles
https://github.com/jacekschae/conduit/blob/master/src/conduit/events.cljs#L128-L144
(btw there's https://github.com/Day8/re-frame-http-fx-2, but the readme warns that it's not ready)
After the data is loaded successfully, the :get-articles-success
is dispatched
https://github.com/jacekschae/conduit/blob/master/src/conduit/events.cljs#L146-L152
And the db
is updated with articles, the subscriptions are updated (all of the Layer 2 and some of the Layer 3), the UI is rerendered where the changed subscriptions were used.