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

Repo.parallel can accept objects #452

Closed nhunzaker closed 6 years ago

nhunzaker commented 6 years ago

This commit updates repo.parallel such that it can accept plain JavaScript objects. In this case, the return payload is an object who's keys match the shape provided.

This also allows generator actions to yield objects

function getPost (id) {
  return fetch(`/posts/${id}`)
}

function getComments (id) {
  return fetch(`/posts/${id}/comments`)
}

function getPostWithComments (id) {
  return function * (repo) {
    let { post, comments } = yield { post: repo.push(getPost, id), comments: repo.push(getComments, id) }

    post.comments = comments

    return post
  }
}

repo.push(getBlogPost, 1)
codecov-io commented 6 years ago

Codecov Report

Merging #452 into repo-parallel-upstream will increase coverage by 0.52%. The diff coverage is 72.72%.

Impacted file tree graph

@@                    Coverage Diff                     @@
##           repo-parallel-upstream     #452      +/-   ##
==========================================================
+ Coverage                   95.61%   96.14%   +0.52%     
==========================================================
  Files                          33       30       -3     
  Lines                        1118     1038      -80     
  Branches                      204      199       -5     
==========================================================
- Hits                         1069      998      -71     
+ Misses                         45       36       -9     
  Partials                        4        4
Impacted Files Coverage Δ
packages/microcosm/src/utils.js 95.89% <0%> (-2.73%) :arrow_down:
packages/microcosm/src/coroutine.js 48% <0%> (+5.14%) :arrow_up:
packages/microcosm/src/action.js 99.14% <100%> (+1.7%) :arrow_up:
packages/microcosm/src/install-devtools.js 66.66% <0%> (-33.34%) :arrow_down:
packages/microcosm/src/effect-engine.js 94.44% <0%> (-5.56%) :arrow_down:
packages/microcosm/src/domain-engine.js 97.05% <0%> (-1.48%) :arrow_down:
packages/microcosm/src/microcosm.js 98.11% <0%> (-0.95%) :arrow_down:
packages/microcosm/src/addons/action-button.js
packages/microcosm/src/addons/action-form.js
... and 5 more

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 d4f4c92...67525bb. Read the comment docs.