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;
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
add a comment |
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
add a comment |
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
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
rxjs race-condition redux-observable cancellation
asked Mar 24 at 18:12
Lin ShenLin Shen
123311
123311
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
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).
add a comment |
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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).
add a comment |
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).
add a comment |
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).
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).
answered Mar 25 at 11:04
Tom CummingTom Cumming
51628
51628
add a comment |
add a comment |
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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