This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-12-20
Channels
- # admin-announcements (1)
- # bangalore-clj (4)
- # beginners (176)
- # boot (38)
- # cider (9)
- # clara (1)
- # clojars (9)
- # clojure (290)
- # clojure-belgium (25)
- # clojure-berlin (2)
- # clojure-dusseldorf (10)
- # clojure-italy (1)
- # clojure-russia (141)
- # clojure-sg (1)
- # clojure-spec (40)
- # clojure-uk (38)
- # clojurebridge (19)
- # clojurescript (148)
- # code-reviews (37)
- # community-development (7)
- # cursive (27)
- # datomic (71)
- # editors-rus (3)
- # events (1)
- # heroku (1)
- # hoplon (16)
- # jobs (5)
- # lambdaisland (3)
- # lein-figwheel (211)
- # luminus (3)
- # off-topic (52)
- # om (18)
- # onyx (49)
- # overtone (3)
- # pedestal (48)
- # protorepl (7)
- # rdf (2)
- # re-frame (61)
- # reagent (3)
- # timbre (2)
- # untangled (69)
@oliy your re-learn
look interesting
https://github.com/oliyh/re-learn
Ready for prime time?
I guess I'm asking: is it ready to add to: https://github.com/Day8/re-frame/blob/master/docs/External-Resources.md
hello folks - does anyone know how to write a single reg-sub
that does one or more subscriptions, depending on the app state? probably an anti-pattern but doable with reg-sub-raw
something like
(reg-sub
:sorted-items
(fn [_ _] (subscribe (get-in db [:some-subscriber]))) ;; here, a dynamic one depending on app state but dont have the db. how to do this?
(fn [items _]
(sort items))
@mikethompson thanks! Not quite yet - there are a few small bugs and features to do before it's ready to be unleashed on an unsuspecting world
Anyone aware of larger public apps written in re-frame 0.8.0+?
Hi, I remember there is a doc article which explained why use []
to build a component instead of using ()
. But I cannot find it right now. Can anyone help me? I've been searching for it for two hours...
@cmal I'm not sure which one you mean, but there is an explanation in the official Reagent tutorial https://reagent-project.github.io
Ahh, I remember maybe I read about that in the wiki. I've been search the docs not the wikis. maybe in wikis. I'll go to there and have a look.
Is this because of react will not rerender when its props change if the props were not actually used in the component.
@oliy re-learn
looks really useful, thanks for sharing it. We've definitely got a use-case in mind for it, any eta for its release please?
In the re-frame README I read:
(defn items-view
[]
(let [items (subscribe [:query-items])] ;; source items from app state
[:div (map item-render @items])) ;; assume item-render already written
Shouldn’t this be a form-2 component, since it will now create subscription every time the component is re-rendered?@borkdude: I also confused about this. But it seems that I have read in somewhere this is a form-2 comp and omit the (fn []) because of no args. I am not sure, still hope others to explain.
@borkdude you can now use subscriptions in form-1 components, introduced in 0.9.0 I think
@martinklepsch is that documented how it works?
@borkdude please refer to the change log for details, afk right now
@borkdude See reference to issue #218 in https://github.com/Day8/re-frame/blob/master/CHANGES.md#headline It has actually been a thing since v0.8. But formally recognised (in docs etc) in v0.9
@mikethompson I'd just like to say re-frame's documentation is intelligible and comprehensive. My thanks to you and others in the community who've contributed, it's fantastic.
@mikethompson I had exactly the situation you are describing in this comment:
https://github.com/Day8/re-frame/issues/218#issuecomment-252470445 (corner case 1)
I wondered about this:
> When x changes, the view re-renders, creating a new subscription. The old one is disposed of. No need of dynamic subscriptions.
Can’t this go wrong somehow, when you deref the subscription once and render the [:div (str @sub)]
, what happens when x
is the same, but the subscription value changes - what will trigger the re-render?
@borkdude that's the standard case: view rerenders because the value of the subscription changes
@kkruit thanks! Pleased to hear it is going well for you.
@mikethompson I’m not sure if that is true. E.g. in the case of this Reagent component, it does not work:
(defn foo []
(let [x (r/atom 1)]
[:button {:on-click #(swap! x inc)} (str @x)]))
Hmm. I must not be understanding your question. I can't see the connection between the code above and the original question I answered. Re-reading
https://www.dropbox.com/s/8s8zh0mle5c5qhh/Screenshot%202016-12-20%2021.57.39.png?dl=0
well, subscriptions behave more or less the same as r/atoms in the sense that they will trigger a re-render when they change. But when you generate one during your render, then render once and it goes out of scope, it seems to me that will never trigger a re-render again (unless the argument to the function changes)
@borkdude I promise it works a treat :-)
1. rerender functions capture
their input reactions (so "going out of scope" is not a problem)
2. re-frame is caching reactions (so it can do signal de-duplication)
Signal deduplication came in with v0.8, and that's the underlying reason this all works. See explanation at top of #218
@mikethompson Cool, so it works because of a more complex implementation than Reagent + r/atoms
Subscriptions have always been reactions, rather than r/atoms, but yes, v0.8 introduced a lower level caching of reactions
Should all be explained in #218, hopefully
Check: https://www.dropbox.com/s/tkbuuxd0vkhrwzd/Screenshot%202016-12-20%2022.22.11.png?dl=0
More confirmation: https://www.dropbox.com/s/bfxa9b95cq4jdkd/Screenshot%202016-12-20%2022.25.33.png?dl=0
@borkdude: What are the last couple of screenshots checking and confirming?
@shaun-mahood correct behavior of subscriptions in form-1 components
Ahh good :) I've used them quite a bit in form-1 since they started working, just got confused following throught the conversation.
@borkdude: yeah, it takes away one of the significant gotchas from earlier versions.
thanks @mikethompson 🙂
@borkdude no problem
Be sure to also look at the new Infographics: https://github.com/Day8/re-frame/blob/master/docs/EventHandlingInfographic.md https://github.com/Day8/re-frame/blob/master/docs/SubscriptionInfographic.md These are not relevant at all to what we were talking about .... I'm just keen to seem them read :-)
@mikethompson: Are those infographics available in an editable form? Curious how they're made :)
I should put the figma files into the repo
Now I’m actually starting to wonder why this didn’t work in Reagent: https://www.dropbox.com/s/1142j6n0pjll6l4/Screenshot%202016-12-20%2023.14.08.png?dl=0
When I click the button, a re-render is triggered. Looks like the atom isn’t updated properly or something?
Funny, when I add a println after the on-click:
click #<Atom: 1>
after click #<Atom: 2>
but then followed by
re-render #<Atom: 1>
@borkdude: I've had to re-read the page at https://github.com/Day8/re-frame/wiki/Creating%20Reagent%20Components an embarrasing number of times to realize (and remember) how all of that works :)