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

Remove ability to reset Microcosm on construction #436

Closed nhunzaker closed 6 years ago

nhunzaker commented 6 years ago

This commit removes support for the ability to reset state when a Microcosm is created.

let repo = new Repo({}, {
  planets: [ 'earth', 'mars', 'jupiter']
})

You mostly see this in tests, and it looks goofy. It's also easy to miss the third argument, which tells Microcosm to deserialize the data (like take string JSON and turn it into an object). Beyond that, there are a couple of other reasons:

  1. I only want one way to reset state
  2. It can be confusing to look at constructors that include seed data, particularly when deserialized
  3. This is part of an effort to reduce some extraneous use cases to improve learnability/useabillity
  4. You can't listen to failure (repo.reset().onError(...))

I also took at pass at improving some tests around instantiation options while I was at it.

codecov-io commented 6 years ago

Codecov Report

Merging #436 into master will decrease coverage by 3.24%. The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master    #436      +/-   ##
=========================================
- Coverage   74.15%   70.9%   -3.25%     
=========================================
  Files          44      44              
  Lines        1362    1368       +6     
  Branches      253     255       +2     
=========================================
- Hits         1010     970      -40     
- Misses        292     330      +38     
- Partials       60      68       +8
Impacted Files Coverage Δ
packages/microcosm/src/microcosm.js 100% <ø> (ø) :arrow_up:
packages/microcosm/src/history.js 100% <100%> (ø) :arrow_up:
packages/microcosm/src/addons/action-button.js 0% <0%> (-100%) :arrow_down:
packages/microcosm/src/addons/action-queue.js 40% <0%> (-40%) :arrow_down:

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 2ef27ab...e3ddf72. Read the comment docs.

efatsi commented 6 years ago

👍