Fork me on GitHub
#re-frame
<
2018-11-20
>
jaihindhreddy-duplicate15:11:15

Where can I learn about co-effects? In the context of re-frame and otherwise.

Braden Shepherdson17:11:16

I found the description as "side-causes" quite illuminating too

Braden Shepherdson17:11:12

I've got a view with two inputs, both of which use on-input

Braden Shepherdson17:11:38

typing in one of them causes the whole area to be re-rendered, and I lose focus. the other one works fine.

manutter5121:11:21

Re-renders are triggered by subscriptions. Make sure each of your fields has a separate subscription for its own data, as opposed to having one subscription return the data for the whole form, and it should render each field separately.

manutter5121:11:45

If it doesn’t, and you can post some code, I could take a look at it.

urzds17:11:42

When trying to combine re-frame and devcards, it only makes sense to use devcards for reagent components that are the domino 5 of re-frame, is that correct? Or is there something else I can use devcards for in this setup?

devurandom20:11:57

The re-frame-template uses defroute inside a function (defn app-routes...). Why was it done that way? It seems unusual to me to def anything inside a function.

Braden Shepherdson20:11:59

defroute is sliiightly misnamed, since it doesn't def any vars in the Clojure sense.

gadfly36120:11:28

@devurandom if i recall, it was a quirk of using secretary which uses macros to define the routes and the timing mattered

devurandom20:11:25

@braden.shepherdson But the secretary readme shows that the route can later be used as a function in that namespace...?

devurandom20:11:09

(defroute users-path "/users" []
  (js/console.log "Users path"))
(users-path) ;; => "/users"

devurandom20:11:21

@gadfly361 I tried to remove the wrapping function and call defroute in the global context, as well as secretary/set-config! and hook-browser-navigation!. And I ran into the issue that now the :active-panel is not anymore set upon loading the application. I have to call (secretary/dispatch! js/window.location.hash) (roughly, writing that from memory) during the "load" event on js/window to make the application show the right content. Could that be the timing problem you mentioned?

devurandom20:11:07

And if secretary is behaving so unreliably, is there something better?

gadfly36120:11:58

I personally use bide .. I know bidi is also popular and reitit is new one

jaide21:11:07

If I want to dispatch a fetch action when visiting a page, where do I call dispatch? I’m using the reitit router.

Braden Shepherdson21:11:12

I stand corrected; I didn't know you could call a route like a function.

jaide21:11:52

Oh wait I see it

jaide21:11:00

I subscribe to :navigate I think

jaide21:11:17

Err setup a navigate effect

Braden Shepherdson21:11:49

anyone with insight into my problems with a form, above?

abdullahibra21:11:40

If I would make a streaming service to show the updates coming from server to update the re-frame db, how can I make the client subscribe with for example Kafka channel which will have the output of streaming output

devurandom21:11:38

@gadfly361 In bide I would then (re-frame/dispatch [:active-panel :foobar]) within a case or cond statement on the route name and query parameters? Do you have an example?

abdullahibra21:11:15

so the should be as simple as possible, ui client "re-frame", Kafka to keep output of streaming, streaming service "which do processing and push to Kafka" how can I make the three parts connected together?

abdullahibra21:11:50

Anyone try this before or have advice on this?

abdullahibra21:11:00

Thanks in advance

gadfly36121:11:44

@devurandom lein new re-frame foobar +gadfly for an example ... that is a hidden profile and makes no promises to the user, but is uses bide as a router

mikethompson21:11:09

@urzds yeah, re-frame does not currently play well with devcards. Although i seem to remember that people have found various hacks.

devurandom21:11:18

@mikethompson But I can use devcards for the limited use-case of playing with domino 5 in re-frame? Without those defcards (and thus e.g. reagent) ever getting in contact with the actual data that is stored by re-frame?

manutter5122:11:06

@abdullahibra I haven’t played with streaming to the browser myself, but I found this, maybe it would be helpful? https://github.com/larrychristensen/messenjer

mikethompson22:11:47

@jayzawrotny the fetch action would normally be initiated by the logic that knows about the change in page, nt by the page itself (which is just a rendering of current state)

jaide22:11:25

Gotcha. Sounds like I should be setting up an effect handler for the :navigate event the luminus app dispatches on init and nav actions.

mikethompson22:11:30

Probably read that FAQ entry first

jaide22:11:40

I actually read that FAQ entry which is what lead me to believe that I should be loading data as an effect instead of putting it in the view on an on-component-did-mount or similar lifecycle method.

jaide22:11:51

Right now I’m grappling with events -> event handlers aspect. Currently a google history handler listens to the NAVIGATE event and dispatches a [:navigate route] event. The :navigate route is then put into the db from a reg-event-db call. So what I’m trying to find the answer to is if I should create an additional reg-event-fx for :navigate to potentially dispatch a :fetch-page-data event or if I should be using one reg-event-fx that handles both updating the db and dispatching the subsequent fetch event.

jaide22:11:58

I believe I have my :fetch-page-data event and handler setup but now I’m trying to learn how to connect :navigate -> both update the db and dispatch :fetch-page-data.

jaide22:11:11

But thank you for the links. I’ll get to them shortly!

mikethompson22:11:33

@devurandom yes, correct. You can use reagent with devcards