Fork me on GitHub
#re-frame
<
2019-11-18
>
grounded_sage12:11:59

Has anyone used Apollo with reframe?

lilactown17:11:19

on my last project, I used apollo alongside re-frame. apollo dealt with fetching data and re-frame dealt with UI state

grounded_sage19:11:01

Do you know of any code references publicly available? I think it’s pretty straight forward but would love to see how someone else did it.

lilactown20:11:55

I open sourced a very early draft of an integration with reagent and apollo-client

lilactown20:11:14

the idea is to wrap the apollo-client observable in a Reaction and then return that

lilactown20:11:21

you can probably use that as a starting point

grounded_sage20:11:50

Awesome. Thank you. I’ll take a look sometime tomorrow. I’m seeing if I can convince the start up I am on to switch to cljs. Key things I need is Material design and Apollo and the switch will likely be pretty easy.

JonR18:11:45

Wondering if anyone here might have any guidance/tips on dynamic subscriptions. I have tried to stay away from them for a while after reading in the docs that they are bad. It isn't clear now though if that's the case. Best I can see now you can have dynamic subs which take another sub as an arg? What about a dynamic sub that takes a none re-frame/reagent atom/reaction?

isak23:11:02

@jon693 I haven't had any problems with them, and use them all the time. I'd stick to just passing paths though, not instances of subscriptions or atoms. It is hard to give good advice on it, because you kind of have to make guesses about what parts of the app-state/subscription structure graph are unlikely to change. (The ones that won't are the ones that are unlikely to cause problems when referred to in dynamic subscriptions).

JonR23:11:42

cool, thanks for the response!

JonR23:11:58

I'm usually wanting it for something like tracking a set of selected ids

JonR23:11:45

then when I want to render some indication of that I'm on the fence about passing the subscribed set down the tree and just check if each id is in it or create a sub where I pass the id and do that in the rf handler

JonR23:11:11

dynamic sub for each view that is

JonR23:11:33

which also just creates a bunch more subs and makes my 10x bloated...

isak23:11:35

Oh, I guessed wrong - I thought you were worried about the problems dynamic subs might cause if you overuse them and then want to refactor. For performance, I've had a similar situation to what you are describing (I think). I made a dynamic subscription (A) that used another subscription (B), where B computed something (like a map) that made it so A was trivial to compute. Still a good amount of subs, but each was quick. Not sure if that is applicable in your case, hard to say without knowing what is involved.