mirror of
https://github.com/status-im/re-frame.git
synced 2025-02-22 14:58:12 +00:00
Docs Tinkering
This commit is contained in:
parent
5628ea3f14
commit
55a0dfe2d0
@ -1,13 +1,21 @@
|
||||
## Namespaced Ids
|
||||
|
||||
## What About Event 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?
|
||||
|
||||
As an app gets bigger, you'll tend to get clashes on event ids. 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` ?).
|
||||
|
||||
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`.
|
||||
|
||||
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.
|
||||
|
||||
You see ClojureScript allows the namespace in a keyword to be a 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.
|
||||
Naturally, you'll take advantage of this by using keyword namespaces
|
||||
which are both unique and descriptive.
|
||||
|
@ -46,4 +46,4 @@ A high level reagent view has a subscription to :active-panel and will switch to
|
||||
|
||||
```
|
||||
|
||||
Continue to [Namespaced Keywords](Namespaced-Keywords.md) to reduce clashes on event ids.
|
||||
Continue to [Namespaced Keywords](Namespaced-Keywords.md) to reduce clashes on ids.
|
||||
|
Loading…
x
Reference in New Issue
Block a user