Liking cljdoc? Tell your friends :D

Table Of Contents

Namespaced Ids

As an app gets bigger, you'll tend to get clashes on ids - event-ids, or query-ids (subscriptions), etc.

One panel will need to dispatch an :edit event and so will another, but the two panels will have different handlers. So how then to not have a clash? How then to distinguish between one :edit event and another?

Your goal should be to use event-ids which encode both the event itself (:edit ?) and the context (:panel1 or :panel2 ?).

Luckily, ClojureScript provides a nice easy solution: use keywords with a synthetic namespace. Perhaps something like :panel1/edit and :panel2/edit.

You see, ClojureScript allows the namespace in a keyword to be a total fiction. I can have the keyword :panel1/edit even though panel1.cljs doesn't exist.

Naturally, you'll take advantage of this by using keyword namespaces which are both unique and descriptive.


Previous: Navigation       Up: Index       Next: Loading Initial Data

Can you improve this documentation? These fine people already did:
Shaun Mahood, Daniel Compton & Mike Thompson
Edit on GitHub

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close