Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Repo.parallel can accept objects #452

Merged
merged 3 commits into from
Nov 13, 2017
Merged

Conversation

nhunzaker
Copy link
Contributor

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
Copy link

codecov-io commented Nov 10, 2017

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%) ⬇️
packages/microcosm/src/coroutine.js 48% <0%> (+5.14%) ⬆️
packages/microcosm/src/action.js 99.14% <100%> (+1.7%) ⬆️
packages/microcosm/src/install-devtools.js 66.66% <0%> (-33.34%) ⬇️
packages/microcosm/src/effect-engine.js 94.44% <0%> (-5.56%) ⬇️
packages/microcosm/src/domain-engine.js 97.05% <0%> (-1.48%) ⬇️
packages/microcosm/src/microcosm.js 98.11% <0%> (-0.95%) ⬇️
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.

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
@nhunzaker nhunzaker force-pushed the object-shape-repo-parallel branch from 334a910 to 67525bb Compare November 13, 2017 14:55
@nhunzaker nhunzaker changed the base branch from repo-parallel-upstream to master November 13, 2017 14:56
@nhunzaker nhunzaker merged commit c418759 into master Nov 13, 2017
@nhunzaker nhunzaker deleted the object-shape-repo-parallel branch December 13, 2017 13:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants