NgRx dispatched an invalid actionngrx Effects: Are actions dispatched by one effect processed immediately by other effects?ngrx dispatching action on component (associated with a route) initngrx error: Actions must have a type propertyNGRX effect only triggering success action once on multiple dispatchesClass Property is undefined in ngrx effectsHow to catch an ngrx action triggered from effect in UI component?NGRX action is dispatched but effect is not firingMultiple actions within a NGRX effectNGRX effect dispatched an invalid action
Teferi's Time Twist and Gideon's Sacrifice
Is declining an undergraduate award which causes me discomfort appropriate?
Are there examples of rowers who also fought?
Implementation of the Jacobi Symbol in C
What kind of chart is this?
Name for a function whose effect is canceled by another function?
What is this airplane that sits in front of Barringer High School in Newark, NJ?
How are で and いう being used in this context?
How much steel armor can you wear and still be able to swim?
Counterfeit checks were created for my account. How does this type of fraud work?
King or Queen-Which piece is which?
How can I ping multiple IP addresses at the same time?
What preparations would Hubble have needed to return in a Shuttle?
I found a password with hashcat but it doesn't work
I just entered the USA without passport control at Atlanta airport
Can a character learn spells from someone else's spellbook and then sell it?
Boundaries and Buddhism
reverse a call to mmap()
How can a clan of females defend themselves in the ancient world against wandering bands?
If the mass of the Earth is decreasing by sending debris in space, does its angular momentum also decrease?
How can I prevent a user from copying files on another hard drive?
Bent arrow under a node
Freewill and rewarding dogs
Is there any possible way to get these hearts as Adult Link?
NgRx dispatched an invalid action
ngrx Effects: Are actions dispatched by one effect processed immediately by other effects?ngrx dispatching action on component (associated with a route) initngrx error: Actions must have a type propertyNGRX effect only triggering success action once on multiple dispatchesClass Property is undefined in ngrx effectsHow to catch an ngrx action triggered from effect in UI component?NGRX action is dispatched but effect is not firingMultiple actions within a NGRX effectNGRX effect dispatched an invalid action
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
The problem here is mainly because of ofType(). I have simple action where user is dispatching a type then request is send to the backend, as response it will return an array of an object which will be passed as new dispatched action. The problem is that with new version of ngrx there is no way to specify ofType() of actions$ because first we need to use pipe() so maps are not processed in one type...
Here is my implementation:
@Effect()
getGrades = this.actions$
.pipe(
ofType(StudentActions.TRY_SET_SUBJECTS),
mergeMap((action: StudentActions.TrySetSubjects) =>
const id = action.payload.id;
return this.httpClient.get(`http://localhost:8080/api/v1/student/$id/grades`)
),
map((response: any[]) =>
console.log('StudentEffects -> getGrades')
const subjects: Subject[] = response
return [
new StudentActions.SetSubjects(subjects)
]
)
);
Here is how it would work with previous versions:
@Effect()
getGrades = this.actions$
.ofType(StudentActions.TRY_SET_SUBJECTS)
.pipe(
mergeMap((action: StudentActions.TrySetSubjects) =>
const id = action.payload.id;
return this.httpClient.get(`http://localhost:8080/api/v1/student/$id/grades`)
),
map((response: any[]) =>
console.log('StudentEffects -> getGrades')
const subjects: Subject[] = response
return [
new StudentActions.SetSubjects(subjects)
]
)
);
How can process response and dispatch new StudentActions.SetSubjects(subjects) with the new version?
Any hint would be helpful, thank you in advance.
EDIT
Actually there was problem with maps. At first I've used mergeMap and then just map. I've changed it to mergeMap and them concatMap. Not sure if concatMap is good choice but it waits until previous subscription ends so it sound like a good choice. Everything works fine.
angular typescript ngrx ngrx-effects
add a comment |
The problem here is mainly because of ofType(). I have simple action where user is dispatching a type then request is send to the backend, as response it will return an array of an object which will be passed as new dispatched action. The problem is that with new version of ngrx there is no way to specify ofType() of actions$ because first we need to use pipe() so maps are not processed in one type...
Here is my implementation:
@Effect()
getGrades = this.actions$
.pipe(
ofType(StudentActions.TRY_SET_SUBJECTS),
mergeMap((action: StudentActions.TrySetSubjects) =>
const id = action.payload.id;
return this.httpClient.get(`http://localhost:8080/api/v1/student/$id/grades`)
),
map((response: any[]) =>
console.log('StudentEffects -> getGrades')
const subjects: Subject[] = response
return [
new StudentActions.SetSubjects(subjects)
]
)
);
Here is how it would work with previous versions:
@Effect()
getGrades = this.actions$
.ofType(StudentActions.TRY_SET_SUBJECTS)
.pipe(
mergeMap((action: StudentActions.TrySetSubjects) =>
const id = action.payload.id;
return this.httpClient.get(`http://localhost:8080/api/v1/student/$id/grades`)
),
map((response: any[]) =>
console.log('StudentEffects -> getGrades')
const subjects: Subject[] = response
return [
new StudentActions.SetSubjects(subjects)
]
)
);
How can process response and dispatch new StudentActions.SetSubjects(subjects) with the new version?
Any hint would be helpful, thank you in advance.
EDIT
Actually there was problem with maps. At first I've used mergeMap and then just map. I've changed it to mergeMap and them concatMap. Not sure if concatMap is good choice but it waits until previous subscription ends so it sound like a good choice. Everything works fine.
angular typescript ngrx ngrx-effects
your implementation is correct.ofType
will still be able to detect the correct action type. what exactly is not working as expected?
– jahller
Mar 25 at 10:02
1
Everything is fine until return of new StudentActions.SetSubjects(subjects). It will throw dispatched an invalid action exception but if effect contains only one map it will be returned successfully.
– Mateusz Gebroski
Mar 25 at 15:53
add a comment |
The problem here is mainly because of ofType(). I have simple action where user is dispatching a type then request is send to the backend, as response it will return an array of an object which will be passed as new dispatched action. The problem is that with new version of ngrx there is no way to specify ofType() of actions$ because first we need to use pipe() so maps are not processed in one type...
Here is my implementation:
@Effect()
getGrades = this.actions$
.pipe(
ofType(StudentActions.TRY_SET_SUBJECTS),
mergeMap((action: StudentActions.TrySetSubjects) =>
const id = action.payload.id;
return this.httpClient.get(`http://localhost:8080/api/v1/student/$id/grades`)
),
map((response: any[]) =>
console.log('StudentEffects -> getGrades')
const subjects: Subject[] = response
return [
new StudentActions.SetSubjects(subjects)
]
)
);
Here is how it would work with previous versions:
@Effect()
getGrades = this.actions$
.ofType(StudentActions.TRY_SET_SUBJECTS)
.pipe(
mergeMap((action: StudentActions.TrySetSubjects) =>
const id = action.payload.id;
return this.httpClient.get(`http://localhost:8080/api/v1/student/$id/grades`)
),
map((response: any[]) =>
console.log('StudentEffects -> getGrades')
const subjects: Subject[] = response
return [
new StudentActions.SetSubjects(subjects)
]
)
);
How can process response and dispatch new StudentActions.SetSubjects(subjects) with the new version?
Any hint would be helpful, thank you in advance.
EDIT
Actually there was problem with maps. At first I've used mergeMap and then just map. I've changed it to mergeMap and them concatMap. Not sure if concatMap is good choice but it waits until previous subscription ends so it sound like a good choice. Everything works fine.
angular typescript ngrx ngrx-effects
The problem here is mainly because of ofType(). I have simple action where user is dispatching a type then request is send to the backend, as response it will return an array of an object which will be passed as new dispatched action. The problem is that with new version of ngrx there is no way to specify ofType() of actions$ because first we need to use pipe() so maps are not processed in one type...
Here is my implementation:
@Effect()
getGrades = this.actions$
.pipe(
ofType(StudentActions.TRY_SET_SUBJECTS),
mergeMap((action: StudentActions.TrySetSubjects) =>
const id = action.payload.id;
return this.httpClient.get(`http://localhost:8080/api/v1/student/$id/grades`)
),
map((response: any[]) =>
console.log('StudentEffects -> getGrades')
const subjects: Subject[] = response
return [
new StudentActions.SetSubjects(subjects)
]
)
);
Here is how it would work with previous versions:
@Effect()
getGrades = this.actions$
.ofType(StudentActions.TRY_SET_SUBJECTS)
.pipe(
mergeMap((action: StudentActions.TrySetSubjects) =>
const id = action.payload.id;
return this.httpClient.get(`http://localhost:8080/api/v1/student/$id/grades`)
),
map((response: any[]) =>
console.log('StudentEffects -> getGrades')
const subjects: Subject[] = response
return [
new StudentActions.SetSubjects(subjects)
]
)
);
How can process response and dispatch new StudentActions.SetSubjects(subjects) with the new version?
Any hint would be helpful, thank you in advance.
EDIT
Actually there was problem with maps. At first I've used mergeMap and then just map. I've changed it to mergeMap and them concatMap. Not sure if concatMap is good choice but it waits until previous subscription ends so it sound like a good choice. Everything works fine.
angular typescript ngrx ngrx-effects
angular typescript ngrx ngrx-effects
edited Mar 26 at 5:15
Mateusz Gebroski
asked Mar 25 at 6:12
Mateusz GebroskiMateusz Gebroski
77112
77112
your implementation is correct.ofType
will still be able to detect the correct action type. what exactly is not working as expected?
– jahller
Mar 25 at 10:02
1
Everything is fine until return of new StudentActions.SetSubjects(subjects). It will throw dispatched an invalid action exception but if effect contains only one map it will be returned successfully.
– Mateusz Gebroski
Mar 25 at 15:53
add a comment |
your implementation is correct.ofType
will still be able to detect the correct action type. what exactly is not working as expected?
– jahller
Mar 25 at 10:02
1
Everything is fine until return of new StudentActions.SetSubjects(subjects). It will throw dispatched an invalid action exception but if effect contains only one map it will be returned successfully.
– Mateusz Gebroski
Mar 25 at 15:53
your implementation is correct.
ofType
will still be able to detect the correct action type. what exactly is not working as expected?– jahller
Mar 25 at 10:02
your implementation is correct.
ofType
will still be able to detect the correct action type. what exactly is not working as expected?– jahller
Mar 25 at 10:02
1
1
Everything is fine until return of new StudentActions.SetSubjects(subjects). It will throw dispatched an invalid action exception but if effect contains only one map it will be returned successfully.
– Mateusz Gebroski
Mar 25 at 15:53
Everything is fine until return of new StudentActions.SetSubjects(subjects). It will throw dispatched an invalid action exception but if effect contains only one map it will be returned successfully.
– Mateusz Gebroski
Mar 25 at 15:53
add a comment |
1 Answer
1
active
oldest
votes
Is this what you're looking for?
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%2f55332130%2fngrx-dispatched-an-invalid-action%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
Is this what you're looking for?
add a comment |
Is this what you're looking for?
add a comment |
Is this what you're looking for?
Is this what you're looking for?
answered Mar 25 at 11:02
timdeschryvertimdeschryver
3,1441313
3,1441313
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%2f55332130%2fngrx-dispatched-an-invalid-action%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
your implementation is correct.
ofType
will still be able to detect the correct action type. what exactly is not working as expected?– jahller
Mar 25 at 10:02
1
Everything is fine until return of new StudentActions.SetSubjects(subjects). It will throw dispatched an invalid action exception but if effect contains only one map it will be returned successfully.
– Mateusz Gebroski
Mar 25 at 15:53