re-frame-10x/docs/HyperlinkedInformation/Diffs.md

26 lines
1.4 KiB
Markdown
Raw Permalink Normal View History

This document explains what you are seeing in sections
labelled "Only Before" and "Only After".
2018-01-17 12:25:41 +00:00
In various places, `re-frame-trace` allows you to inspect values like `app-db`.
Knowing the current value is useful, but
you are sometimes more interested to know how a value has changed.
The value might be `X` before the start of this epoch, and
ended up as `X'`. So `re-frame-trace` will be showing you `X'` but you might woonder
how `X` and `X'` are different. What got added or removed, and what was modified?
2018-01-17 12:25:41 +00:00
To show such differences, `re-frame-trace` chooses to do a calculation best explained by this pseudo code:
2018-01-18 00:50:18 +00:00
```clj
(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).
2018-01-17 12:25:41 +00:00
By [looking at the docs](https://clojuredocs.org/clojure.data/diff) for `clojure.data/diff`, you'll see
2018-01-18 01:31:14 +00:00
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"
respectively. The 3rd element is ignored because it's what hasn't changed, which isn't interesting.
2018-01-17 12:25:41 +00:00
So, to correctly interpret "Only Before" and "Only after", you'll need to spend a bit
2018-01-17 12:25:41 +00:00
of time properly familiarising yourself with how `clojure.data/diff` works, but
it will be a worthwhile investment of your time.