mirror of
https://github.com/status-im/re-frame.git
synced 2025-02-23 15:28:09 +00:00
Add new FAQ entry on Normalised databases
This commit is contained in:
parent
93cfd747fa
commit
e7114d1a6c
@ -5,7 +5,8 @@
|
|||||||
- added [API documentation](/docs/API.md)
|
- added [API documentation](/docs/API.md)
|
||||||
- added [testing docs](/docs/Testing.md)
|
- added [testing docs](/docs/Testing.md)
|
||||||
- added [a new mental model](/docs/MentalModelOmnibus.md#on-dsls-and-machines)
|
- added [a new mental model](/docs/MentalModelOmnibus.md#on-dsls-and-machines)
|
||||||
- added [a new FAQ entry](docs/FAQs/When-Does-Dispatch-Happen.md) on dispatch processing
|
- added [a new FAQ entry](/docs/FAQs/When-Does-Dispatch-Happen.md) on dispatch processing
|
||||||
|
- added [a new FAQ entry](/docs/FAQs/DB_Normalisation.md) on representing normalised data in `app-db`.
|
||||||
|
|
||||||
#### Breaking
|
#### Breaking
|
||||||
|
|
||||||
|
16
docs/FAQs/DB_Normalisation.md
Normal file
16
docs/FAQs/DB_Normalisation.md
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
### Question
|
||||||
|
|
||||||
|
`app-db` contains a `map`. How do I store normalised data in a `map`,
|
||||||
|
bettering mirroring the structure in my server-side database?
|
||||||
|
|
||||||
|
### Answer
|
||||||
|
|
||||||
|
These libraries might be interesting to you:
|
||||||
|
- [SubGraph](https://github.com/vimsical/subgraph)
|
||||||
|
- [pull](https://github.com/juxt/pull)
|
||||||
|
|
||||||
|
If you want to go whole hog and ditch `app-db` and embrace DataScript,
|
||||||
|
then you'll find [re-posh](https://github.com/denistakeda/re-posh) interesting.
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -5,9 +5,10 @@
|
|||||||
2. [How can I use a subscription in an Event Handler](UseASubscriptionInAnEventHandler.md)
|
2. [How can I use a subscription in an Event Handler](UseASubscriptionInAnEventHandler.md)
|
||||||
2. [How do I use logging method X](Logging.md)
|
2. [How do I use logging method X](Logging.md)
|
||||||
3. [Dispatched Events Are Null](Null-Dispatched-Events.md)
|
3. [Dispatched Events Are Null](Null-Dispatched-Events.md)
|
||||||
4. [Why implement re-frame in `.cljc` files](Why-CLJC.md)
|
4. [Why is re-frame implemented in `.cljc` files](Why-CLJC.md)
|
||||||
5. [Why do we need to clear the subscription cache when reloading with Figwheel?](Why-Clear-Sub-Cache.md)
|
5. [Why do we need to clear the subscription cache when reloading with Figwheel?](Why-Clear-Sub-Cache.md)
|
||||||
6. [How can I detect exceptions in Event Handlers?](CatchingEventExceptions.md)
|
6. [How can I detect exceptions in Event Handlers?](CatchingEventExceptions.md)
|
||||||
|
7. [How do I store normalised data in app-db?](DB_Normalisation.md)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -24,11 +24,11 @@ be injected into the `coeffects` of that handler via an interceptor.
|
|||||||
|
|
||||||
A sketch:
|
A sketch:
|
||||||
```clj
|
```clj
|
||||||
(re-frame.core/reg-event-fx ;; handler must access coeffects, so use -fx
|
(re-frame.core/reg-event-fx ;; handler must access coeffects, so use -fx
|
||||||
:event-id
|
:event-id
|
||||||
(inject-sub [:query-id :param]) ;; <-- will inject subscription value into coeffects
|
(inject-sub [:query-id :param]) ;; <-- interceptor will inject subscription value into coeffects
|
||||||
(fn [coeffect event]
|
(fn [coeffects event]
|
||||||
(let [sub-val (:something coeffect)] ;; obtain subscription value
|
(let [sub-val (:something coeffects)] ;; obtain subscription value
|
||||||
....)))
|
....)))
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -36,7 +36,7 @@ Notes:
|
|||||||
1. `inject-sub` is an interceptor which will get the subscription value and add it to coeffects (somehow)
|
1. `inject-sub` is an interceptor which will get the subscription value and add it to coeffects (somehow)
|
||||||
2. The event handler obtains the value from coeffects
|
2. The event handler obtains the value from coeffects
|
||||||
|
|
||||||
So how to write this interceptor?
|
So, how to write this `inject-sub` interceptor?
|
||||||
|
|
||||||
### Solutions
|
### Solutions
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@ How long after I call `dispatch` will the event be processed?
|
|||||||
### Answer
|
### Answer
|
||||||
|
|
||||||
The answer is "it depends", but [this comment in the code](https://github.com/Day8/re-frame/blob/master/src/re_frame/router.cljc#L8-L60)
|
The answer is "it depends", but [this comment in the code](https://github.com/Day8/re-frame/blob/master/src/re_frame/router.cljc#L8-L60)
|
||||||
might give you the answers you want.
|
might provide you the answers you seek.
|
||||||
|
|
||||||
|
|
||||||
Up: [FAQ Index](README.md)
|
Up: [FAQ Index](README.md)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user