Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Mar 30 23:11
    greenkeeper[bot] commented #711
  • Mar 30 23:11

    greenkeeper[bot] on @types

    chore(package): update @types/n… chore(package): update lockfile… (compare)

  • Mar 30 19:14

    greenkeeper[bot] on @typescript-eslint

    chore(package): update @typescr… chore(package): update lockfile… (compare)

  • Mar 30 18:55

    greenkeeper[bot] on @typescript-eslint

    chore(package): update @typescr… chore(package): update lockfile… (compare)

  • Mar 27 17:43
    greenkeeper[bot] commented #711
  • Mar 27 17:43

    greenkeeper[bot] on @types

    chore(package): update @types/n… chore(package): update lockfile… (compare)

  • Mar 25 06:42
    greenkeeper[bot] commented #711
  • Mar 25 06:42

    greenkeeper[bot] on @types

    chore(package): update @types/n… chore(package): update lockfile… (compare)

  • Mar 24 07:12

    greenkeeper[bot] on webpack-4.42.1

    (compare)

  • Mar 24 07:10

    greenkeeper[bot] on webpack-4.42.1

    chore(package): update webpack … chore(package): update lockfile… (compare)

  • Mar 23 17:39
    greenkeeper[bot] commented #697
  • Mar 23 17:36
    greenkeeper[bot] commented #714
  • Mar 23 17:36

    greenkeeper[bot] on @typescript-eslint

    chore(package): update @typescr… chore(package): update lockfile… (compare)

  • Mar 23 17:20

    greenkeeper[bot] on @typescript-eslint

    chore(package): update @typescr… chore(package): update lockfile… (compare)

  • Mar 22 21:42
    jayphelps commented #719
  • Mar 22 21:42

    jayphelps on master

    doc(middleware): Highlight code… (compare)

  • Mar 22 21:42
    jayphelps closed #719
  • Mar 22 15:25
    greenkeeper[bot] commented #711
  • Mar 22 15:25

    greenkeeper[bot] on @types

    chore(package): update @types/n… chore(package): update lockfile… (compare)

  • Mar 20 08:47
    piecioshka opened #720
Kevin Ghadyani
@Sawtaytoes
@da101by_gitlab Depends. If you're using Redux-Observable, it does all that for you. https://redux-observable.js.org/docs/basics/Epics.html
SuryaSJ
@SuryaSJ
Hi ,
I have tried retryWhen , but getting the error in console
Uncaught TypeError: You provided 'undefined' where a stream was expected. You can provide an Observable, Promise, Array, or Iterable.
at subscribeTo (subscribeTo.ts:28)
at subscribeToResult (subscribeToResult.ts:37)
at RetryWhenSubscriber.error (retryWhen.ts:74)
at MapSubscriber.Subscriber._error (Subscriber.ts:144)
at MapSubscriber.Subscriber.error (Subscriber.ts:114)
at subscribeToPromise.ts:15
My epic structure is
.switchMap(().pipe( map(),retryWhen(),catch()
Evert Bouw
@evertbouw
can you post the whole code? I'm not sure if you deleted too much
SuryaSJ
@SuryaSJ
export const fetching= action$ =>
action$.pipe(
ofType(actions.FETCH().type),
switchMap(() =>
from(ajax.get(url)).pipe(
map(({ data }) => ({
type: 'SET_DATA',
payload: data
})),
retryWhen(errors$ => {
errors$.pipe(
delay(1000),
map(() => {
action.payload.retries -= 1;
if (action.payload.retries === 0) {
throw errors$;
}
}),
);
}),
catchError(error =>
of({
type: 'HANDLE_ERROR',
payload: error,
error: true,
}),
),
),
),
);
Evert Bouw
@evertbouw
uhh you missed a return in the retryWhen function
SuryaSJ
@SuryaSJ
correct
now clicked
thanku
my bad
SuryaSJ
@SuryaSJ
How to check whether retryWhen is calling the api for the count of retires
SuryaSJ
@SuryaSJ
Now it retrying the inner observable but not the outer observable
SuryaSJ
@SuryaSJ
Any one having idea to test forkjoin using sinon.fakeServer
Richard Van Camp
@RikuVan
@Sawtaytoes you keep delivering blog posts on redux-observable and/rxjs stuff with useful tips. Keep up the good writing!
Kevin Ghadyani
@Sawtaytoes
@RikuVan :thumbsup: They're useful to you?
Richard Van Camp
@RikuVan
definitely
Kevin Ghadyani
@Sawtaytoes
@RikuVan What specifically have you found helpful?
Richard Van Camp
@RikuVan
@Sawtaytoes well I just checked out the web sockets examples in your blog (just now realize it is not a new post) to refactor my own code for streams-based api. I had a working version but I like the idea of use takeUntil and startWith operators instead of the way I had done it. So having examples of handling particular scenarios with some reasons given for the approach allows you to compare and rethink your own code. I also like that in some of your posts you have question orthodox ways to do thinks, like implicit dispatching in redux-obsrervable. I don't necessarily always agree but it widens my view to what is possible and forces me to defend my own code. Some of your posts are long and thorough. I personally prefer these deeper, involved posts although sometimes, here is how to do x kind of posts can be useful too.
Jack Anderson
@JackCA
Are there any best practices surrounding refactoring long epics? I've experimented with emitting new async actions (that don't modify the actual state) just for the sake of having more discreet epics
Kevin Ghadyani
@Sawtaytoes
@JackCA Yes! That's a valid way of doing it. Actions never have to modify state; in fact, they could simply trigger other actions.
Jack Anderson
@JackCA
@Sawtaytoes Nice, that's good to know. It does seem like a lot of manual labor generating the actions and epics but it works
Bram Hautekiet
@bram_hautekiet_twitter

I have a question about the forkJoin operator. In this example I want to execute 2 actions that perform ajax calls, and combine their results.

export default action$ => action$.pipe(
  ofType(ACTIONS.GET_SETTINGS),
  mergeMap(action => 
    forkJoin(
      of(getSetting(1)), // getSetting returns an action object
      of(getSetting(2)),
    ).pipe(
      mergeMap((results) => {
        console.log(results[0]),
        console.log(results[1]),
        return { type: 'store_settings', results};
      }),
    );
  ),
);

What happens is that in the results I got my 2 actions back, instead of their results (so they are not executed).
Any hints how to adapt my code?

Kevin Ghadyani
@Sawtaytoes
@bram_hautekiet_twitter I thought forkJoin took an object, and you get back the keys in your pipeline.
Mustaflex
@Mustaflex

Hello guys,
question: I working on a new project and it uses react and redux-thunk. We want to switch to redux-observables and we want to do it gradually.
As a test case, I transformed one of the store entry into using Epics and it works as expected first than we have some unexpected behavior.
Basically after the action and changes triggered by our epic, the next unrelated action reverts back the state to where it was before our epic fired.

did you guys have any success with using redux-observables and redux-thunk at the same time?

Thank you!

Kevin Ghadyani
@Sawtaytoes

@Mustaflex Redux-Observable and Redux-Thunk work together without issue. One thing to keep in mind is that Redux-Observable runs after reducers whereas Redux-Thunk runs immediately (meaning before reducers).

What's the code you're working with where you're having the issue?

Mustaflex
@Mustaflex
Hello Kevin, thanks for taking time to answer. I think my issues might be from some other refactoring and not directly related to redux-observables.
Kevin Ghadyani
@Sawtaytoes
:thumbsup:
Dean Radcliffe
@deanius
What are some reasons i might get a 'executing a canceled action' error in a mocha suite that tests react code (that uses RxJS)? StackOverflow is surprisingly bare on the subject (pun).
Kevin Ghadyani
@Sawtaytoes
Are you using Redux-Observable? It sounds strange to be using RxJS directly with React and getting an error specifying action. Either way, it might be that you killed the observable, but you're still trying to do a .next on it.
gardezii
@gardezii

@gardezii
Hi guys, I hope all of you are doing fine. Can you please tell what is it that I'm doing wrong over here ?
const createRequest = (ajaxParameters) => ajax(ajaxParameters).pipe( takeUntil([ofType("END")]) )

I'm using rxJs and redux-observables. The problem is if I add takeUntil, it stops triggering all the epics. Any idea what is it I'm doing wrong over here?
I've created an API file in which I'm creating the get, post, put, delete request. All the epic file import the request functions from this file.

gardezii
@gardezii
Kevin Ghadyani
@Sawtaytoes
@gardezii Answered in StackOverflow.
gardezii
@gardezii
@Sawtaytoes I've added a comment to your answer
Paul
@jaffrepaul
hello all, any good resources on unit testing epics?
Kevin Ghadyani
@Sawtaytoes

A few people have asked actually. Unit testing epics is pretty simple, but look at RxJS testing to get an idea.

In this case, to test an epic, you're calling a function that takes a new Subject(), a new BehaviorSubject(store.getState()), and potential dependencies that you can separately mock.

Dimitrii Lyomin
@lemind
Screenshot from 2020-03-27 09-33-42.png
Hello there.
Trying to migrate to rxjs6
I've got a error.
Kevin Ghadyani
@Sawtaytoes
@lemind Without any code, there's not an easy way to help. Also, we'd need to know the steps you took to get that error.
Dimitrii Lyomin
@lemind
Screenshot from 2020-03-27 09-54-47.png
it is main file. I've got it when app started.
I use mock epic here. Now there is a goal to start it; that is all
Dimitrii Lyomin
@lemind
versions
Screenshot from 2020-03-27 10-00-07.png
Ionut Achim
@monojack
@lemind , I think, somewhere in your epics, an import is messed up. Don't rely on vscode auto-imports. Double check that.
Kevin Ghadyani
@Sawtaytoes
@lemind Does it work with this code you posted at least?

Because you're still importing rootEpic. rootEpic2 should at least work by itself. If so, then the issue, like @monojack said, could be related to imports.

Basically, you're importing X when you should be importing {X}. And the error is saying "you passed in an object when you should've passed in an operator".

Dimitrii Lyomin
@lemind
Hey. I've solved this issue. It was old(RxJs 5 style) import paths in the other files. Thanks!
@monojack @Sawtaytoes