Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 00:33
    hexadecimalmoods opened #1983
  • Nov 21 23:01
    polomoshnov commented #694
  • Nov 21 22:55
    polomoshnov commented #1744
  • Nov 21 22:37
    neaumusic closed #1982
  • Nov 21 22:37
    neaumusic commented #1982
  • Nov 21 22:33
    changeset-bot[bot] commented #1982
  • Nov 21 22:33
    neaumusic opened #1982
  • Nov 21 18:10
    iBobo5 commented #1980
  • Nov 21 14:55
    mattiassamskar commented #1899
  • Nov 21 11:40
    whitehorse622 commented #1722
  • Nov 21 06:32
    polomoshnov commented #1744
  • Nov 21 05:53
    polomoshnov commented #1744
  • Nov 20 01:55
    jothreddy edited #1981
  • Nov 20 01:51
    jothreddy opened #1981
  • Nov 20 01:50
    jothreddy commented #1977
  • Nov 19 22:45
    Andarist commented #1980
  • Nov 19 16:57
    iBobo5 opened #1980
  • Nov 19 11:36
    samitha9125 closed #1973
  • Nov 19 11:34
    samitha9125 opened #1979
  • Nov 17 11:29
    arnaudambro commented #1910
Chris LeBlanc
@spacesuitdiver
Hello, I'm having trouble understanding how/when to use fork/all... when registering "rootSagas"... I'm using redux-saga-requests and my sagas are broken into redux "duck" like modules, any duck may fire redux saga requests.
What I'm currently facing though I think is unrelated... for some reason my takeLatest from one module is not responding to another's action fired I think
in my rootSaga I have yield createRequestInstance(); yield watchRequests(); all([fork(duck1), fork(duck2)]);
Chris LeBlanc
@spacesuitdiver
I guess to make a digestible question, what's the relationship between something that is forked and takeLatest?
Tormen Raßmann
@trassmann
takeLatest takes the action from the standard channel and forks a new task, if the same action is fired again while an old task is still running it gets cancelled AFAIK
and a forked task is just a forked task
you need to yield the all effect as well though
yield all([fork(duck1), fork(duck2)]);
Mladen Petrović
@mladenp
Hey all, i am getting error call: argument of type {context, fn} has undefined or null while trying to compose sagas.
I have no idea whats wrong
Monteiro Steed
@SteedMonteiro

Hello @everyone

We’re looking for React/React Native engineers to work as part of our community. We have multiple projects and missions, where you choose on what you want to work. There is no hiring process, so keep your resumate... it’s an open organisation, here only our work matter :)

StudioLabs is a 100% remote international company, originally founded in Paris, France. We help companies develop their applications by providing them skills of developers and designers from around the world. We believe in living a life of freedom, where freelancers can choose their missions.

Join our community here:http://bit.ly/2w2BHYO

rwong
@foodforarabbit
@rishichawda hey I hope this reply isn't too late, but you can have sagas call each other in a chain, so you can consolidate all your generic error handling in one place. For example, instead of takeEvery(GET_RESOURCE_ACTION, getResources) and have getResources call the api directly, you can have getResources handle composing parameters / handling api response. In the middle, getResources might yield call callAndHandleApiErrors which deals with figuring out which api-specific things you need like headers, endpoints, etc... and dealing with api-level response errors. And within callAndHandleApiErrors you might have yet another saga that does the actual fetch call itself, and handles network-level issues. For example, if you want to auto-retry an api call X amount of times, you might pass that as a parameter down to the fetch* saga which can handle retrying your api call, and if it fails X times then it can dispatch an error and return something to the callAndHandleApiErrors saga so that it knows that it can proceed (e.g. just return null or something).
vitalicwow
@vitalicwow
Using redux-saga-test-plan, any idea why my generator that returns a Promise would cause test to time out? Getting error: "Timeout - Async callback was not invoked within the 5000ms timeout specified by jest.setTimeout."
3kgoldie
@3kgoldie
Can someone explain how the saga middleware works under the hood? Like I understand how middlewares work and I understand what take/takeEvery ect does, but I don't understand how the saga middleware does its job of getting the actions to the right sagas. Or maybe point me to a resource that explains it?
Ahmad R
@harvester-klirk
hi guys , how do i pass an argument from the action creator to my saga ?
AmyBlankenship
@AmyBlankenship
In the documentation on task cancellation (https://redux-saga.js.org/docs/advanced/TaskCancellation.html), it shows how to test that a task was cancelled, but it seems to me to be waaay more important to test that the code in the task that actually does the real cancellation (if yield(cancelled) {abortController.abort()} for example) runs. But I haven't been able to figure out how you create a generator as a task and cancel it so that I can test this. I think I understand how to spy on the constructor for AbortController so I can look at what happened--I just have no clue how to make it happen in a test scenario. The code would normally get cancelled by takeLatest.
@harvester-klirk , if you're asking what I think you're asking, the action itself will be the argument, and you'll look at its properties to determine what you should do. In addition, you can get access to the state using select() to fill in any gaps.
AmyBlankenship
@AmyBlankenship
For anyone else wanting to test the finally logic in a canceled saga, I found the answer here https://stackoverflow.com/questions/46166401/unit-testing-redux-saga-task-cancellation https://github.com/redux-saga/redux-saga/issues/266#issuecomment-216087030. Hope this helps someone
Matti Järvinen
@nemeciii_twitter
Kinda related to @AmyBlankenship ´s question. I'm testing a full saga with runSaga. How would I add another action in there so I can test that it cancels the previous one?
Alan.He
@alanhg
for v1.o, catch not work? const rootTask = sagaMiddleware.run(rootSaga)
rootTask.done.catch(...)
Alan.He
@alanhg
Alan.He
@alanhg
anybody know the issue
Aleksander Vognild Burkow
@aleksanb
@gilbsgilbs i'm having a look at your dtslint branch
I'm not having any trouble running the tests, and think i might be getting other erors than you described
i get straight-up normal errors:
Error: /Users/aleksandervognildburkow/Projects/redux-saga/packages/core/types/ts3.5/channels.test.ts:24:1
ERROR: 24:1    expect  TypeScript@next: Expected an error on this line, but found none.
ERROR: 32:1    expect  TypeScript@next: Expected an error on this line, but found none.
ERROR: 45:1    expect  TypeScript@next: Expected an error on this line, but found none.
ERROR: 47:1    expect  TypeScript@next: Expected an error on this line, but found none.
ERROR: 51:1    expect  TypeScript@next: Expected an error on this line, but found none.
ERROR: 56:1    expect  TypeScript@next: Expected an error on this line, but found none.
ERROR: 58:1    expect  TypeScript@next: Expected an error on this line, but found none.
ERROR: 82:1    expect  TypeScript@next: Expected an error on this line, but found none.
ERROR: 90:1    expect  TypeScript@next: Expected an error on this line, but found none.
ERROR: 99:1    expect  TypeScript@next: Expected an error on this line, but found none.
ERROR: 112:1   expect  TypeScript@next: Expected an error on this line, but found none.
ERROR: 116:1   expect  TypeScript@next: Expected an error on this line, but found none.
Alan.He
@alanhg

In order for the execution exception of an effect to not affect the whole, I created a wrapper function. For example, the following adds safety to each effect, which solves the problem.

But if my effect is very large, it is very time consuming and not elegant to manually increase the safety. I want to know if there is any way, such as a loop function to automatically add safety to each effect, which makes the code more beautiful.

wrapper function

import { call } from 'redux-saga/effects';

export function safe(sagaFn) {
  return function* (action) {
    try {
      return yield call(sagaFn, action);
    } catch (e) {
      console.error('[react-demo | Saga Unhandled Exception] This error should be fixed or do some pre check in saga effects function.');
      console.error(e);
    }
  };
}

saga.js

function* mySaga() {
    yield takeEvery('USER_FETCH', safe(fetchUserEffects));
    yield takeEvery('TEST_SAGA', safe(testSagaEffects));
    yield takeEvery('TEST_SAGA', safe(testSagaEffects2));
}
@aleksanb
Gilbert Gilb's
@gilbsgilbs

@aleksanb Just came across your message. Thanks for reaching out! The errors you were pointing out occurred because TS wasn't able to resolve some types and was using any type as a replacement. So this was actually highly related to the issue I had.

As I said in the PR, I finally found a way to debug and fix it and the PR got merged into master :tada: . Unfortunately, it doesn't seem to work on @Andarist machine and he's unable to release, not sure why. If you want to give it a try 🤷‍♂️ .

@Andarist whenever you feel like it, we can spend some time to try to figure out what's wrong. Just tell me.
Aleksander Vognild Burkow
@aleksanb
amazing!
Great to see this being released now.
I upgraded our local project, the only thing missing now is for us to get const someresult = yield call(someTypedFunction) to work, but that's blocked on typescript adding more support, right?
Mateusz Burzyński
@Andarist
Yes
This cant yet be expressed in TS
There has been discussion around adding eslint plugins with autofixer that would annotate those for u
Prateek Chachra
@prateekchachra
Hey guys
needed some help
Trying to setup redux saga
The method in 'takeLatest' is being called more than 6000 times in one go, which is hanging my app
And it's only supposed to be called just once
Ryan Bas
@ryanbas21
Anyone familiar with redux-saga-test plan able to help me stop banging my head on the wall
Menci
@Menci
Does Saga effects need to be async? What for a sync effect in my app?
e.g. A library requires me to call .setLocale() when changing locale. It's a sync side effect.
Mateusz Burzyński
@Andarist
@Menci effects can be synchronous, yield call(() => 'foo') works
Phan Dang Dien
@phandd

I guys, I'm struggling in finding a proper way to use saga in my app. For example I have a fetch action and a notification function to push notification when the fetch action failed or succeeded.

The question is where should I put UI-related logic like notification, confirmation modals, router redirection...? Should I put it right in the saga?

That doesn't seem to be a good choice for me because I want the app logic to be separated from UI logic. That way I can later use my app logic for mobile and other devices and the only thing I need is to rebuild the UI itself. Can someone tell me what is the best practice for saga? Thank you!

A Flores
@unflores
@phandd Hrm...I think that sagas are mainly for managing async things, I think of it as a place to put my 3rd party interactions(3rd party being another server, my own server, a service of some sort, etc) Usually, I will take that data, and feed it into redux. Redux is piped in to my individual components.
wrt ui related things, if it is self contained within a single component I will actually handle it there. If it were something that had to do that had to communicate over multiple components I might use a saga? but I would probably just modify my store and have the respective components update themselves from redux.
for router redirection, I will usually render a redirection tag based on certain critiria directly in my component.
A Flores
@unflores
sometimes if I have something that needs to have a timeout before fetching more data, I will put that type of thing in sagas as well
Prateek Chachra
@prateekchachra
@prateekchachra
Hello everyone! How do you guys optimize API calls?
My API call takes about 1300 ms at max on postman, but on react native it takes 5 times that time