question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to call put effect in loop correctly?

So i wanna do something like this:

function* dispatchAll (data) {
  yield put({
    type: 'TYPE',
    payload: data
  })
}
function* foo ({ payload }) {
  try {
    const data = yield R.map(api, payload) // R = ramda.js
    yield R.map(dispatchAllPosts, data)
  } catch (err) {
    //
  }
}

But while i call put in loop app is freezing. Any advices?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

6reactions
yelouaficommented, Aug 9, 2016

if you want to yield multiple calls in parallel, use the snippet of @sergej-s; to put the results in parallel you can yield an array of put effects

yield R.map(item => put({type: '...', payalod: item}), data)
3reactions
Andaristcommented, May 20, 2018

@ArtBIT yield actions.map(put) might not work, because put will be called with both action and index arguments. puts signature is function put(channel, action) { ... } so it would create wrong effect (or just throw when validating.

Also you should wrap this with all effect which is preferred way of starting parallel effects.

So the final code should look like this:

yield all(actions.map(ac => put(ac)))
Read more comments on GitHub >

github_iconTop Results From Across the Web

put her in the loop definition | English dictionary for learners
If someone is in the loop, they are part of a group of people who make decisions about important things, or they know...
Read more >
Keep (someone) in the loop - Idioms by The Free Dictionary
To keep someone informed about and/or involved in something, such as a plan or project, especially that which involves or pertains to a...
Read more >
Be in the loop definition and meaning - Collins Dictionary
If someone is in the loop, they are part of a group of people who make decisions about important things, or they know...
Read more >
putting her/him in the loop | WordReference Forums
Sure! Anytime you want to include someone who is currently not involved, it's a common expression to say "include them in the loop"....
Read more >
Loop videos or playlists on YouTube - Android - Google Support
When watching YouTube, you can play a video or playlist on repeat by looping it. To repeat a video: Go to the watch...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found