Closed nhunzaker closed 6 years ago
Merging #484 into master will decrease coverage by
0.33%
. The diff coverage is81.81%
.
@@ Coverage Diff @@
## master #484 +/- ##
=========================================
- Coverage 98.54% 98.2% -0.34%
=========================================
Files 29 28 -1
Lines 686 669 -17
Branches 134 128 -6
=========================================
- Hits 676 657 -19
- Misses 8 10 +2
Partials 2 2
Impacted Files | Coverage Δ | |
---|---|---|
packages/microcosm/src/ledger.js | 88.88% <0%> (-11.12%) |
:arrow_down: |
packages/microcosm/src/domain.js | 97.95% <100%> (+0.04%) |
:arrow_up: |
packages/microcosm/src/microcosm.js | 100% <100%> (ø) |
:arrow_up: |
packages/microcosm-dom/src/utilities.js |
Continue to review full report at Codecov.
Legend - Click here to learn more
Δ = absolute <relative> (impact)
,ø = not affected
,? = missing data
Powered by Codecov. Last update af36b87...43a50bd. Read the comment docs.
What it does
This commit changes the Domain class such that it extends from the Subject prototype. A subject is kind of like a stream of values over time. They are a special kind of observable that makes it easier to send updates to multiple subscribers.
Subjects have their own state, which allows a couple of nice things:
toJSON method
can just returnthis.domains
.JSON.stringify
should take care of everything else by calling the subsequenttoJSON
methods on domains.dispatch
directly on the domain itself. This isn't quite true yet, as Domains require a microcosm history object, but one idea is to give each domain their own unique history.This means the
repo.answers
namespace can be removed. You can now get updates to a domain simply by accessing the domain itself. This required some Presenter tests to be updated:Before this change, there was an additional
answers
namespace on repo. You'd have to subscribe to a domain update viarepo.answers["domain-key"]
. This commit consolidates that namespace while also simplify some serialization techniques because domains now fully track their own state.Long term, I'd like to add some new methods to observables, like
map
. That would let you do stuff like:It also means that you can build more complicated view models by composing domains into an object:
This is sort of the next step for
getModel
. Long term, I can see how this could start to term into a more sophisticated query language. One that could probably also handle data fetching.