Fork me on GitHub

Do people ever create events with compound keys at all, is there a reason not to do it? E.G.:

  [:a-key dynamic-key :final-key]
  (fn [_ _]


Not sure about dynamic-key, but I sometimes use compound keys that are just vectors of keywords. Usually it's just to avoid having to create another multimethod.


Thanks! Yeah, that's what I'm trying avoid as well. dynamic-key works I was just wondering whether there was some reason to not rely on the compound key that I couldn't see.


Eh, not really a robust reason but some tools don't like them. At least, quite some time go re-frame-10x used to display them incorrectly, IIRC. That seems to be fixed now though. I think there was something with re-frisk as well. But I haven't seen anything like that recently, so yeah, probably nothing to worry about.


And by finding an issue in my code, I immediately realized a downside for this approach. You cannot have default values. For me, this is a significant advantage of multimethods. Of course, there's also dispatch values hierarchy but I don't use it that often.


Ah, that's a good point. I don't have a default in this case but it makes me think I should just stick to multimethods to keep everything consistent.


how do compound keys work? I dont’ remember seeing those mentioned in the docs


Compound keys are no different from regular keyword keys. re-frame doesn't care what you use as a key, keywords are just a common practice.


very interesting discussion. @U2FRKM4TW, would you mind giving an example where compound keys are useful please?


@U7ESY38HJ Anywhere you'd use a multimethod but where using one is more clunky and not justified enough to not use a compound key.


I don't think I've ever used a multi method when registering event handlers. I can't think of a use case 😄


Well, suppose you have a few panel types, and for each panel you need to fetch some data when a button is pressed somewhere on the panel. There are multiple ways to do it. One of them is to use a compound key like [:fetch-data panel-kind].