Tweak subscription documentation
This commit is contained in:
parent
31ba95ba1b
commit
db1496bfe3
|
@ -71,7 +71,7 @@ Above, I suggested this:
|
||||||
@(rf/subscribe [:time-str])])
|
@(rf/subscribe [:time-str])])
|
||||||
```
|
```
|
||||||
|
|
||||||
But that may offend your aesthetics. Too much noise with those `@`?
|
But that may offend your aesthetics. Too much noise with those two `@`?
|
||||||
|
|
||||||
To clean this up, we can define a new `listen` function:
|
To clean this up, we can define a new `listen` function:
|
||||||
```clj
|
```clj
|
||||||
|
@ -91,6 +91,16 @@ And then rewrite:
|
||||||
So, at the cost of writing your own function, `listen`, the code is now less noisy
|
So, at the cost of writing your own function, `listen`, the code is now less noisy
|
||||||
AND there's less chance of us forgetting an `@` (which can lead to odd problems).
|
AND there's less chance of us forgetting an `@` (which can lead to odd problems).
|
||||||
|
|
||||||
|
### LambdaIsland Naming (LIN)
|
||||||
|
|
||||||
|
I've ended up quite liking [the alternative names](https://lambdaisland.com/blog/11-02-2017-re-frame-form-1-subscriptions)
|
||||||
|
suggested by [Lambda Island Videos](https://lambdaisland.com/):
|
||||||
|
|
||||||
|
```cljs
|
||||||
|
(def <sub (comp deref re-frame.core/subscribe)) ;; aka listen (above)
|
||||||
|
(def >evt re-frame.core/dispatch)
|
||||||
|
```
|
||||||
|
|
||||||
### Say It Again
|
### Say It Again
|
||||||
|
|
||||||
So, if, in code review, you saw this view function:
|
So, if, in code review, you saw this view function:
|
||||||
|
@ -102,8 +112,8 @@ So, if, in code review, you saw this view function:
|
||||||
```
|
```
|
||||||
What would you (supportively) object to?
|
What would you (supportively) object to?
|
||||||
|
|
||||||
That `sort`, right? Computation in the view. Instead, we want the right data
|
That `sort`, right? Computation in the view. Instead, we want exactly the right data
|
||||||
delivered to the view - its job is to simply make `hiccup`.
|
delivered to the view - no further computation required - the view's job is to simply make `hiccup`.
|
||||||
|
|
||||||
The solution is to create a subscription that delivers items already sorted.
|
The solution is to create a subscription that delivers items already sorted.
|
||||||
```clj
|
```clj
|
||||||
|
@ -143,7 +153,6 @@ it would be flowing through to both views.
|
||||||
|
|
||||||
That sort of efficiency can't happen if this views themselves are doing the `sort`.
|
That sort of efficiency can't happen if this views themselves are doing the `sort`.
|
||||||
|
|
||||||
|
|
||||||
### de-duplication
|
### de-duplication
|
||||||
|
|
||||||
As I described above, two, or more, concurrent subscriptions for the same query will source
|
As I described above, two, or more, concurrent subscriptions for the same query will source
|
||||||
|
|
Loading…
Reference in New Issue