Fork me on GitHub
#re-frame
<
2018-11-27
>
Braden Shepherdson01:11:42

I'm open to variations on the theme, for example having the subscription fire events on creation and disposing, and letting those events control the polling. but that feels like "semantics"; it's essentially the same technique.

Braden Shepherdson01:11:27

@mikethompson I'm able to give this question a chew now if you're around. not sure what time zone you're in and so on. (EST here)

isak15:11:16

I think usually the important thing for correctness is that the "startup" and "cleanup" code can be collocated

jaihindhreddy15:11:07

What are the tradeoffs b/w re-frame and fulcro? Which things are more decomplected here, and there?

urzds15:11:43

re-frame separates data acquisition from rendering using subscriptions. However, data acquisition can fail (data has not yet arrived from backend, query to backend failed completely, ...). Is there a common pattern to handle these cases? "if subscriptions return nil, render this view, else feed the data from the subscriptions into that other view"?

manutter5115:11:20

That’s basically what I do: make a div with a spinner or some other indicator that only displays when the subscription value is nil.

👍 1
Braden Shepherdson15:11:08

yeah, loads of my views are (if @the-sub [:div.real-view ...] [spinner])

urzds15:11:45

What do you do if the query eventually fails? Do you have another (if @error [display-error] [spinner]) in there?

Braden Shepherdson16:11:34

sometimes (when @error-sub [...])

Braden Shepherdson16:11:40

depends on how the errors are to be surfaced.

Braden Shepherdson17:11:34

I seem to have discovered one potential problem with the scheme we were discussing yesterday, of having subs drive the fetching of data.

Braden Shepherdson17:11:26

and that is if multiple other subscriptions depend on the stateful one, it's sensitive about whether it's being run several times or just once.

urzds17:11:33

@braden.shepherdson I enhanced the code by @oliy to store nil in the target key, so that (if-not (contains? target-key) (... ::re-graph/subscribe ...) ...) will not trigger anymore once the first subscription request is sent.

urzds17:11:00

So there will not be any unnecessary network requests. I think re-graph would already discard the additional subscription requests, if it detects that they are duplicates of existing requests, so technically this is not necessary for correctness.

Whiskas19:11:16

so, for some reason it looks that my events.cljs file is not running at startup and my event handlers are not being registered. What is the most commom cause for this?

Whiskas19:11:57

re-frame: no :event handler registered for:

Braden Shepherdson19:11:38

neglecting to :require the events, even though you don't call things in that file.

Braden Shepherdson19:11:45

someone has to require them.

Braden Shepherdson19:11:23

(if you prefer using ::namespaced-keywords then that forces you to import your events and subs so you can ::subs/some-value and such)

Whiskas19:11:50

ooh, got it

Whiskas19:11:58

i was like “what the heck…“haha

Whiskas19:11:19

i think i deleted the requires because of the linter telling me that the imports were not being used

Braden Shepherdson19:11:20

@mikethompson ping re: our discussion, if you've got time now.