This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-12-14
Channels
- # adventofcode (20)
- # arachne (11)
- # beginners (53)
- # boot (342)
- # cider (54)
- # cljs-dev (39)
- # cljsrn (4)
- # clojure (78)
- # clojure-brasil (2)
- # clojure-italy (5)
- # clojure-nl (4)
- # clojure-quebec (1)
- # clojure-russia (90)
- # clojure-sanfrancisco (4)
- # clojure-spec (55)
- # clojure-uk (27)
- # clojurescript (170)
- # core-async (1)
- # core-logic (1)
- # css (1)
- # cursive (8)
- # datomic (83)
- # dirac (5)
- # hoplon (24)
- # lambdaisland (1)
- # lein-figwheel (23)
- # midje (2)
- # off-topic (1)
- # om (4)
- # om-next (7)
- # onyx (74)
- # proton (1)
- # protorepl (22)
- # rdf (2)
- # re-frame (105)
- # reagent (15)
- # ring-swagger (3)
- # rum (4)
- # slack-help (17)
- # spacemacs (14)
- # untangled (62)
- # vim (4)
- # yada (18)
@sandbags (1) like expand all but only for one sub-tree? (2) can't imagine how it should work, can you write steps how you want to use it
hi all, who have tried latest version of https://github.com/flexsurfer/re-frisk is it helpful? subscriptions ,interceptors?
For us, basically expand-all expands our 200ish event/sub/etc. but we just want to see the app-db.
------------- Reminder for everyone. Please do the Clojure survey: https://www.surveymonkey.com/r/clojure2016 ------------
@andre (2) I am very often interested in a nested part of my data structure, but i think this could be difficult as there are GUID keys in the way that make data-add-in
troublesome to use but would, now i think about it for a moment, also make a bookmark unusable... hrmmm
Hello, everyone, i’ve got a question: reg-event-fx has no doc string, is it intended to be used for events that doesn’t modify app-db, so the return value of the function passed to it is ignored?
@pbaille reg-event-fx is a more generalised event handler, it can produce all side effects, including modifying the db
{:db newdb}
to modify db
It shouldn't, yes
I haven't tried it, tho
reg-event-db is sugar so you don't have to return a map with new db everytime
It's just another middleware
re-frame has several implemented instructions, like :dispatch, :dispatch-n, and also :db
reg-event-db wraps the function you give it in middleware that turns it into {:db stuff}
for other middleware to consume and do stuff
@andre, ok I see, Am I suppose to look the source to know that? or is it documented somewhere?
It's in the docs
here: https://github.com/Day8/re-frame/blob/master/docs/EffectfulHandlers.md
new docs in the development https://github.com/Day8/re-frame/blob/develop/README.md#code-for-domino-2
And the readme gets even longer...
@abstruselyarcane Hey! The new readme is shorter
And it has pictures
I liked the old ascii art, but I guess dominoes will have to do
@andre new version of re-frisk looks very good! couldn't get the pop up working previously, now works great.
Hi! A question, that's best pictured with todomvc code, so I'm pasting following line: https://github.com/Day8/re-frame/blob/master/examples/todomvc/src/todomvc/views.cljs#L7
here we see that the todo input just have local atom, and it manages it on its own. Suppose we want to clear the input when some other action occurs, then our only way to do this is to move the input to the app db and just subscribe, right?
Oh, I see the 'editing' in the upper component is doing exactly what I've been wondering. Sorry for vague questions, I'm just wondering where's the distinction between something that's local and something that just have to be in app state and is subject of subscriptions/events...
how can i pass a react element as a prop to other elements in reagent ? I need something similar to <C1 icon={<ICON />}>
Since re-frame is built on top of reagent, you should just be passing vectors around in hiccup
@abstruselyarcane something like this ?
Wait, you want to pass a react component to another react component?
How is the icon represented?
If the icon is a react class
You should be able to pass in a vector that will be used by another component to construct their view
and the button component keep complaining because it expect a react element for icon prop
Oh, youre using a third party lib button
I thought you were talking about a component you controlled
Hmm, maybe dig through reagent docs to see if theres a function that transforms it from hiccup to react?
My google-fu reveals this: https://stackoverflow.com/questions/25797048/how-to-pass-in-a-react-component-into-another-react-component-to-transclude-the
I'm not sure how reagent handles this tho
Look at the create react component section
@abstruselyarcane i did it , i did this (.render (new js/Grommet.Icons.Base.User (clj->js {}) js/window))
Umm, refactor that into a macro?
I'm not the expert here; until somebody comes up with a cleaner way, might as well make it look prettier
the cleaner solution is to use React.createElement
and pass the react compnent to it
@abstruselyarcane despite the nostalgia, we've moved on from ascii art (inspired by @andre) https://github.com/Day8/re-frame/blob/develop/docs/EventHandlingInfographic.md
Looks very pretty, I must admit
@andre try creating diagrams for dynamic subscriptions and events
or are they deprecated?
With v0.8.0 you really don't need dynamic subscriptions any more
Well, if you have local state somewhere that needs to interact with subs, it might be useful
I'm still trying to rewrite my entire data layer with specter, tho
(get-in path)
is just not working anymore
hi, I'm wondering why this is throwing an error: (rf/reg-sub ::db (fn [db _] db)) (println @(rf/subscribe [::db]))
@pbaille: What error are you seeing?
Are you just trying to figure out how subscribe works, or is that pattern necessary in your project?
Ok, in that case I think you should be following the examples - start with https://github.com/Day8/re-frame/tree/master/examples/simple
Subscribe is generally used within a reagent component, so the test you are doing isn't representative of normal use and probably isn't worth troubleshooting
No problem, keep asking questions as you run into problems 🙂
There's nothing really wrong with calling a subscription in standard code, e.g. test code, as long as you are aware it is a slightly different context
but for one shot subscription calls, that is fine
@pbaille at a guess, you should be wrapping those in a do
? Can you show the whole context?
hey all, I’m writing a widget that shows a progression of steps and I’d like to be able to dispatch a step, then wait for a little bit, then dispatch another step, here’s what I have and it works fine, but wondering if anyone can suggest any tips?
I’m only going to have 3 or 4 steps, but might be fun to try and write a macro. Or, also, just curious if anyone else ran into something similar and how you solved it?
@upgradingdave have you seen :dispatch-later ?
awesome, (I thought there might be something already built in). thanks!
@upgradingdave pleasure ... happy to be able to give some help for once 🙂
@upgradingdave also https://github.com/Day8/re-frame-async-flow-fx might be good
depending on how much control you need
@danielcompton: Outside of tests, would there be any issues with calling subscriptions in other places? If I had a regular function call a subscription, and then used that function from multiple places (e.g. a coeffect, event handler, effect) would there be any things that would work differently from subscribing within a reagent component? Does the whole de-duped signal graph magic still work the same. This is all purely theoretical for me, but I've seen a few questions on this channel (particularly with chains of subscriptions) where subscribing directly from within a function may have been the best solution if there are no other major issues, so it would be nice to understand it a bit better so I'm not giving out too much misleading advice 🙂
I should probably write this up, as you're right it is a common question. There's two intertwined issues here though. Should you use subscriptions outside of view functions or other subscriptions, and Can you use subscriptions. I'm still pretty firmly in the should not camp for subscribing in event handlers as part of a production app for conceptual/data flow/unidirectional data cycle reasons. Can you use them? I've never really explored too much down this path, but I know we use one shot subscriptions in tests, and there's also no issue I've found with calling them at the REPL. I haven't really looked to see how the reaction on-dispose is called outside of a view function. Also, there's a weird reagent bug at the moment where you can use a disposed Reaction quite happily, and I think it even keeps running. Then you need to consider the subscription cache, which should be mostly fine, except for cases like https://github.com/Day8/re-frame/blob/develop/docs/FAQs/Why-Clear-Sub-Cache.md. In short, thar be dragons. If you want to call it in testing or for debugging purposes, then I don't see any major issues. But it's not something I'd recommend for production critical code
@danielcompton: That's good info, thanks. I had the impression that things broke outside of components, so it's nice to know that it's mainly a case of "possibly undefined behaviour, probably a bad idea" vs. "won't work".
Yep, good summary