vigetlabs / microcosm

Flux with actions at center stage. Write optimistic updates, cancel requests, and track changes with ease.
http://code.viget.com/microcosm/
MIT License
487 stars 22 forks source link

Clean up Subject, Observable, and History interface #481

Closed nhunzaker closed 6 years ago

nhunzaker commented 6 years ago
  1. Remove start callback. This is in compliance with the ES spec.
  2. Move Observable.hash to Subject.hash. It returns a Subject.
  3. History is now a Subject, eliminating history.updates
  4. Update Flow types. I think the new way Observables are structured is a lot nicer, in terms of Flow.

Why

1. Remove start callback. This is in compliance with the ES spec.

Besides being against the spec, I didn't like how Microcosm 12.x has a open and update command. Most of the time you know if an action has been opened. You just pushed it beyond that, I want to encourage next -> complete to be the same data type.

2. Move Observable.hash to Subject.hash. It returns a Subject.

This just sort of made sense

3. History is now a Subject, eliminating history.updates

I want all major pieces to adhere to the observable spec. I can see subscribing to history updates being useful for tooling. But mostly this is just an attempt at hygiene. Ideally, you could eventually do something like.

codecov-io commented 6 years ago

Codecov Report

Merging #481 into master will decrease coverage by 0.02%. The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #481      +/-   ##
==========================================
- Coverage   97.65%   97.62%   -0.03%     
==========================================
  Files          29       29              
  Lines         681      673       -8     
  Branches      143      143              
==========================================
- Hits          665      657       -8     
  Misses         13       13              
  Partials        3        3
Impacted Files Coverage Δ
packages/microcosm/src/microcosm.js 84.37% <100%> (+0.5%) :arrow_up:
packages/microcosm/src/effect-engine.js 100% <100%> (ø) :arrow_up:
packages/microcosm-dom/src/presenter.js 100% <100%> (ø) :arrow_up:
packages/microcosm/src/subject.js 100% <100%> (ø) :arrow_up:
packages/microcosm-dom/src/action-form.js 100% <100%> (ø) :arrow_up:
packages/microcosm/src/domain-engine.js 98.03% <100%> (+0.08%) :arrow_up:
packages/microcosm/src/observable.js 100% <100%> (ø) :arrow_up:
packages/microcosm-dom/src/action-button.js 100% <100%> (ø) :arrow_up:
packages/microcosm/src/history.js 100% <100%> (ø) :arrow_up:
packages/microcosm/src/coroutine.js 100% <100%> (ø) :arrow_up:

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 462b4bb...95f2801. Read the comment docs.