Improve hyperlinked-to docs on "only before" and "only after"

This commit is contained in:
Mike Thompson 2018-01-25 14:54:40 +11:00 committed by GitHub
parent 532657a44a
commit f0d590f67f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 14 additions and 16 deletions

View File

@ -1,27 +1,25 @@
This document briefly explains what you are seeing in those mysterious sections This document explains what you are seeing in sections
labelled "Only Before" and "Only After". Enlightenment is nigh. labelled "Only Before" and "Only After".
`re-frame-trace` allows you to inspect important values like `app-db`. In various places, `re-frame-trace` allows you to inspect values like `app-db`.
While knowing current values is useful, Knowing the current value is useful, but
you are often more interested to know how a value has changed. you are sometimes more interested to know how a value has changed.
The value might start off as, say, `X` (before the event happened) but The value might be `X` before the start of this epoch, and
ended up as `X'`. How are `X` and `X'` different, you wonder? ended up as `X'`. So `re-frame-trace` will be showing you `X'` but you might woonder
What got added or removed? What was modified? how `X` and `X'` are different. What got added or removed, and what was modified?
So, how then to display changes in a way that's easy to understand? I'm glad you asked. To show such differences, `re-frame-trace` chooses to do a calculation best explained by this pseudo code:
`re-frame-trace` chooses to do a calculation best shown by this pseudo code:
```clj ```clj
(let [[only-before only-after _] (clojure.data/diff X X')] (let [[only-before only-after _] (clojure.data/diff X X')]
...) ...)
``` ```
Remember X is the value immediately `before` (this epoch). And `X'` is the value `after` (the epoch has completed). Remember `X` is the value immediately `before` (this epoch). And `X'` is the value `after` (the epoch has completed).
By [looking at the docs](https://clojuredocs.org/clojure.data/diff) on `diff`, you'll see By [looking at the docs](https://clojuredocs.org/clojure.data/diff) for `clojure.data/diff`, you'll see
that it calculates how two values differ, and returns a triple of values. `re-frame-trace` that it calculates how two values differ, and returns a triple of values. `re-frame-trace`
captures and displays the first two elements of this triple as "only before" and "only after" captures and displays the first two elements of this triple as "only before" and "only after"
respectively. The 3rd element is ignored because it is not very interesting - it says respectively. The 3rd element is ignored because it's what hasn't changed, which isn't interesting.
what hasn't changed, so it isn't shown.
To correctly interpret "Only Before" and "Only after", you'll need to spend a bit So, to correctly interpret "Only Before" and "Only after", you'll need to spend a bit
of time properly familiarising yourself with how `clojure.data/diff` works, but of time properly familiarising yourself with how `clojure.data/diff` works, but
it will be a worthwhile time investment. it will be a worthwhile investment of your time.