Hey and welcome @stefankurcubic2 — I took the liberty to slightly improve the formatting of your question.
I don’t have a clear cut answer to your question but can you show your code that registers the event handler for the event type bus-line/coord that you’re dispatching?
Also maybe elaborate on what you’re trying to achieve by using the multimethod that you pasted.
(reg-event-db
:bus-line/coord
(fn-traced [db [_ coord]]
(assoc db :bus-line/coord coord)))
Well my goal is to make subscription for type of data i need on client.
Basically choose what i want > chsk-send! > return latest data. I got this working.
What this mutlimethod should do is act as a refresher of that data.
I’ve got broadcaster on backend that sends this event bus-line/coord with latest data to subscribed client
i want to dispatch that data (update rf/db) so subscribe can pick it up and display it.
(defmethod -event-msg-handler :bus-line/coord
[{:as ev-msg :keys [?data]}]
(do (println "Push coord from server: %s" ?data)
(rf/dispatch [:bus-line/coord (:coord ?data)])))
(reg-event-db
:bus-line/coord
(fn-traced [db [_ coord]]
(assoc db :bus-line/coord coord)))
So with these two code snippets you are seing the println in the console but you’re not seeing the handler that updates app-db being triggered?
If so a few ideas:
Put a println in the reg-event-db function to get some further visibility into whether it is called
Replace fn-traced with a regular fn just to exclude any issues stemming from that (I don’t know what fn-traced does or where it comes from)
Ensure that the namespace that contains the reg-event-db form is loaded. You could do that by calling re-frame.registrar/get-handler like so (I think):
I know next to nothing about re-frame but it looks like ?data is the vector above? So getting (:coord [:bus-line/coord {...}]) just ends up as (rf/dispatch [:bus-line/coord nil])? Not sure if that matters.