In a redux-observable epic, why can we filter the action stream of a type but still get access the action stream of another typeredux-observable - dispatch multiple redux actions in a single epicEpic not returning stream in Redux-ObservableEmit 2 values from a redux-observable epic when source$ is a single actionUsing RxJS switchMap to only unsubscribe from streams with the same request URL/action payload (redux-observable epics)Dispatching additional actions conditionally from redux-observable epicHow to execute 2 async calls in redux-observable epic and return/dispatch action on result of each oneWhen using redux-observable, from a single action and single stream, how do I dispatch different actions based on filterConvert AJAX in redux to redux-observableHow to test race condition of a redux observable epicWhy ActionsObservable in redux-observable are hot observables?

With Ubuntu 18.04, how can I have a hot corner that locks the computer?

How can I get an unreasonable manager to approve time off?

Did Milano or Benatar approve or comment on their namesake MCU ships?

Can Rydberg constant be in joules?

Extreme flexible working hours: how to control people and activities?

Zeros of the Hadamard product of holomorphic functions

How is John Wick 3 a 15 certificate?

Certain search in list

Is the term 'open source' a trademark?

A IP can traceroute to it, but can not ping

Group Integers by Originality

How did old MS-DOS games utilize various graphic cards?

Can U.S. Tax Forms Be Legally HTMLified?

Arriving at the same result with the opposite hypotheses

Winning Strategy for the Magician and his Apprentice

How to handle self harm scars on the arm in work environment?

What speaks against investing in precious metals?

Does Disney no longer produce hand-drawn cartoon films?

Using "subway" as name for London Underground?

Why can't I use =default for default ctors with a member initializer list

Union with anonymous struct with flexible array member

Is a lack of character descriptions a problem?

Check if three arrays contains the same element

Why can my keyboard only digest 6 keypresses at a time?



In a redux-observable epic, why can we filter the action stream of a type but still get access the action stream of another type


redux-observable - dispatch multiple redux actions in a single epicEpic not returning stream in Redux-ObservableEmit 2 values from a redux-observable epic when source$ is a single actionUsing RxJS switchMap to only unsubscribe from streams with the same request URL/action payload (redux-observable epics)Dispatching additional actions conditionally from redux-observable epicHow to execute 2 async calls in redux-observable epic and return/dispatch action on result of each oneWhen using redux-observable, from a single action and single stream, how do I dispatch different actions based on filterConvert AJAX in redux to redux-observableHow to test race condition of a redux observable epicWhy ActionsObservable in redux-observable are hot observables?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








0















In the cancellation examples of redux-observable official doc, we firstly filter the action stream action$ by a type, and then race an ajax call with the action stream of another type.
I don't understand how can it be possible for action$ of type FETCH_USER_CANCELLED pass through the first ofType(FETCH_USER) filter.



Here is an example



const fetchUserEpic = action$ => action$.pipe(
ofType(FETCH_USER),
mergeMap(action => race(
ajax.getJSON(`/api/users/$action.payload`).pipe(
map(response => fetchUserFulfilled(response))
),
action$.pipe(
ofType(FETCH_USER_CANCELLED),
map(() => incrementCounter()),
take(1)
)
))
);


Why don't we need 'FETCH_USER_CANCELLED' at the first ofType filter?



action$.pipe(
ofType(FETCH_USER, FETCH_USER_CANCELLED),
...


It would be grateful if someone can explain.










share|improve this question




























    0















    In the cancellation examples of redux-observable official doc, we firstly filter the action stream action$ by a type, and then race an ajax call with the action stream of another type.
    I don't understand how can it be possible for action$ of type FETCH_USER_CANCELLED pass through the first ofType(FETCH_USER) filter.



    Here is an example



    const fetchUserEpic = action$ => action$.pipe(
    ofType(FETCH_USER),
    mergeMap(action => race(
    ajax.getJSON(`/api/users/$action.payload`).pipe(
    map(response => fetchUserFulfilled(response))
    ),
    action$.pipe(
    ofType(FETCH_USER_CANCELLED),
    map(() => incrementCounter()),
    take(1)
    )
    ))
    );


    Why don't we need 'FETCH_USER_CANCELLED' at the first ofType filter?



    action$.pipe(
    ofType(FETCH_USER, FETCH_USER_CANCELLED),
    ...


    It would be grateful if someone can explain.










    share|improve this question
























      0












      0








      0








      In the cancellation examples of redux-observable official doc, we firstly filter the action stream action$ by a type, and then race an ajax call with the action stream of another type.
      I don't understand how can it be possible for action$ of type FETCH_USER_CANCELLED pass through the first ofType(FETCH_USER) filter.



      Here is an example



      const fetchUserEpic = action$ => action$.pipe(
      ofType(FETCH_USER),
      mergeMap(action => race(
      ajax.getJSON(`/api/users/$action.payload`).pipe(
      map(response => fetchUserFulfilled(response))
      ),
      action$.pipe(
      ofType(FETCH_USER_CANCELLED),
      map(() => incrementCounter()),
      take(1)
      )
      ))
      );


      Why don't we need 'FETCH_USER_CANCELLED' at the first ofType filter?



      action$.pipe(
      ofType(FETCH_USER, FETCH_USER_CANCELLED),
      ...


      It would be grateful if someone can explain.










      share|improve this question














      In the cancellation examples of redux-observable official doc, we firstly filter the action stream action$ by a type, and then race an ajax call with the action stream of another type.
      I don't understand how can it be possible for action$ of type FETCH_USER_CANCELLED pass through the first ofType(FETCH_USER) filter.



      Here is an example



      const fetchUserEpic = action$ => action$.pipe(
      ofType(FETCH_USER),
      mergeMap(action => race(
      ajax.getJSON(`/api/users/$action.payload`).pipe(
      map(response => fetchUserFulfilled(response))
      ),
      action$.pipe(
      ofType(FETCH_USER_CANCELLED),
      map(() => incrementCounter()),
      take(1)
      )
      ))
      );


      Why don't we need 'FETCH_USER_CANCELLED' at the first ofType filter?



      action$.pipe(
      ofType(FETCH_USER, FETCH_USER_CANCELLED),
      ...


      It would be grateful if someone can explain.







      rxjs race-condition redux-observable cancellation






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Mar 24 at 18:12









      Lin ShenLin Shen

      123311




      123311






















          1 Answer
          1






          active

          oldest

          votes


















          0














          In the above example you are using the unfiltered action$ stream twice. The ofType(FETCH_USER) filter only applies to the subsequent operators in the pipe (aka the mergeMap after it).






          share|improve this answer























            Your Answer






            StackExchange.ifUsing("editor", function ()
            StackExchange.using("externalEditor", function ()
            StackExchange.using("snippets", function ()
            StackExchange.snippets.init();
            );
            );
            , "code-snippets");

            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "1"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













            draft saved

            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55326927%2fin-a-redux-observable-epic-why-can-we-filter-the-action-stream-of-a-type-but-st%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            In the above example you are using the unfiltered action$ stream twice. The ofType(FETCH_USER) filter only applies to the subsequent operators in the pipe (aka the mergeMap after it).






            share|improve this answer



























              0














              In the above example you are using the unfiltered action$ stream twice. The ofType(FETCH_USER) filter only applies to the subsequent operators in the pipe (aka the mergeMap after it).






              share|improve this answer

























                0












                0








                0







                In the above example you are using the unfiltered action$ stream twice. The ofType(FETCH_USER) filter only applies to the subsequent operators in the pipe (aka the mergeMap after it).






                share|improve this answer













                In the above example you are using the unfiltered action$ stream twice. The ofType(FETCH_USER) filter only applies to the subsequent operators in the pipe (aka the mergeMap after it).







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Mar 25 at 11:04









                Tom CummingTom Cumming

                51628




                51628





























                    draft saved

                    draft discarded
















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55326927%2fin-a-redux-observable-epic-why-can-we-filter-the-action-stream-of-a-type-but-st%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

                    Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

                    Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript