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;








2















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.










share|improve this question
























  • 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

















2















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.










share|improve this question
























  • 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













2












2








2








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.










share|improve this question
















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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

















  • 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












1 Answer
1






active

oldest

votes


















2














Is this what you're looking for?



enter image description here






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%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









    2














    Is this what you're looking for?



    enter image description here






    share|improve this answer



























      2














      Is this what you're looking for?



      enter image description here






      share|improve this answer

























        2












        2








        2







        Is this what you're looking for?



        enter image description here






        share|improve this answer













        Is this what you're looking for?



        enter image description here







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Mar 25 at 11:02









        timdeschryvertimdeschryver

        3,1441313




        3,1441313





























            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%2f55332130%2fngrx-dispatched-an-invalid-action%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

            SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

            은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현