-
Notifications
You must be signed in to change notification settings - Fork 405
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature: cancelNewWhenUncompleted #1477
Comments
This is falsy. It works like a I think this feature is unnecessary because it can be kept out of the core framework, if I needed to use an fromEvent(loginButton, 'click')
.pipe(exhaustMap(() => this.store.dispatch(new Login({ username }))))
.subscribe(() => {
console.log('Successfully authenticated...');
}); |
@arturovt https://www.ngxs.io/v/master/recipes/component-events-from-ngxs |
This is too basic. If you want then go for it! 😉 |
Ok then. Thanks for the example. I wanted to prevent using @ViewChild() and fromEvent, because the behavior is going to change in Angular 9 (static property will be removed). But I can manage it with local state of the component. |
I disagree, and a good reason for you guys consider this discussion is: I felt the same feeling as @PeterGursky and I've found this issue topic. Let's create a scenario if you dispatch the same action from services AND multi-components? How do you manage it? you will need to create a singleton service to control the 'another action stream' and all those services/components will need to use that, I think it is a 'overengineer'. With NgRx for example, you can control exactly the specific e.g: @Effect()
loadAnimal = this.actions$.pipe(
ofType(saveAnimal),
// here I can control my flattening strategy
switchMap(([action]) => {
return this.animals.save(action.payload).pipe(
map(animal => new SaveAnimalSuccess(animal)),
catchError(err =>
of(
new SaveAnimalError(
'Failed to save the animal'
)
)
)
);
})
); Any new but I'm able to change the exhaustMap(([action]) => {
return this.animals.save(action.payload).pipe(
map(animal => new SaveAnimalSuccess(animal)),
catchError(err =>
of(
new SaveAnimalError(
'Failed to save the animal'
)
)
)
);
}) e.g: A login system and I don't want to make HTTP multiple calls, just the first one and I wanna ignore until the HTTP call has finished, or any async operation I wanna wait the first one has finished. I can achieve the switchMap behavior with |
I have the same issue on my side. I have some data states which are requesting entities from a api. The actions to load those entities are dispatched from EVERY component which relies on a entity. My current solution to avoid duplicated actions / requests is to check a loading flag in the state model and cancel the action if the flag is already set. I would really welcome a |
For now this can be achieved using the |
@markwhitfeld what do you think move it issue to https://github.com/ngxs/store/discussions? |
Thank you for submitting this feature request.
You are welcome to re-open this issue with a further motivation for why this feature is essential for the core library or plugins. Thanks again
|
I'm submitting a...
What is the motivation / use case for changing the behavior?
Currently, the only ActionOption is cancelUncompleted. It would be convenient to have the opposite behavior, i.e. cancelling the new action, when the previous is not completed. CancelUncompleted works like mergeMap. This feature is the equivalent to exhaustMap.
Current behavior
Expected behavior
The text was updated successfully, but these errors were encountered: