2016-11-06 20:12:24 +00:00
|
|
|
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
|
|
|
|
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
|
|
|
|
## Table Of Contents
|
|
|
|
|
|
|
|
- [Namespaced Ids](#namespaced-ids)
|
|
|
|
|
|
|
|
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
|
|
|
|
|
2016-08-25 11:52:39 +00:00
|
|
|
## Namespaced Ids
|
2016-08-23 21:17:59 +00:00
|
|
|
|
2016-08-25 11:52:39 +00:00
|
|
|
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?
|
2016-08-23 21:17:59 +00:00
|
|
|
|
2016-08-25 11:52:39 +00:00
|
|
|
Your goal should be to use event-ids which encode both the event
|
|
|
|
itself (`:edit` ?) and the context (`:panel1` or `:panel2` ?).
|
2016-08-23 21:17:59 +00:00
|
|
|
|
2016-08-25 11:52:39 +00:00
|
|
|
Luckily, ClojureScript provides a nice easy solution: use keywords
|
|
|
|
with a __synthetic namespace__. Perhaps something like `:panel1/edit` and `:panel2/edit`.
|
2016-08-23 21:17:59 +00:00
|
|
|
|
2016-08-25 11:52:39 +00:00
|
|
|
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.
|
2016-08-23 21:17:59 +00:00
|
|
|
|
2016-08-25 11:52:39 +00:00
|
|
|
Naturally, you'll take advantage of this by using keyword namespaces
|
|
|
|
which are both unique and descriptive.
|
2016-08-28 15:40:00 +00:00
|
|
|
|
2016-11-06 20:12:24 +00:00
|
|
|
***
|
|
|
|
|
2016-08-28 15:40:00 +00:00
|
|
|
Previous: [Navigation](Navigation.md)
|
2016-08-28 15:50:15 +00:00
|
|
|
Up: [Index](README.md)
|
2016-11-06 20:12:24 +00:00
|
|
|
Next: [Loading Initial Data](Loading-Initial-Data.md)
|