Closed vspinu closed 6 years ago
I believe you are asking about the result of this, for the server, or the similar logic on the client side:
(defn- put-server-event-msg>ch-recv!
"All server `event-msg`s go through this"
[ch-recv {:as ev-msg :keys [event ?reply-fn]}]
(let [[ev-id ev-?data :as valid-event] (as-event event)
ev-msg* (merge ev-msg {:event valid-event
:?reply-fn ?reply-fn
:id ev-id
:?data ev-?data})]
(if-not (server-event-msg? ev-msg*)
(warnf "Bad ev-msg: %s" ev-msg) ; Log 'n drop
(put! ch-recv ev-msg*))))
I think, and I could be wrong, but the data inside the event won't be duplicated here. ev-msg
is an object that references id
and ?data
, and event
. event
also references the same data structures in id
and ?data
.
Hi Vitalie,
Do I understand correctly that ?data and id within event-msg are always the same as the first and second elements of event? Why is this seemingly useless repetition?
That's correct - they are the same. The repetition is for historical (backward-compatibility) reasons.
Hope that helps?
Yes. Thanks for the clarification.
Would it be possible to elaborate a bit more on all of the components of the event-msg in the readme's table?
Do I understand correctly that
?data
andid
withinevent-msg
are always the same as the first and second elements ofevent
? Why is this seemingly useless repetition?