-
Notifications
You must be signed in to change notification settings - Fork 405
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(store): complete action results on destroy (#2282)
We complete the `InternalDispatchedActionResults` once the application is destroyed to ensure there are no active subscribers after resources have been cleaned up.
- Loading branch information
Showing
6 changed files
with
38 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { Injectable, OnDestroy } from '@angular/core'; | ||
import { Subject } from 'rxjs'; | ||
|
||
import type { ActionContext } from '../actions-stream'; | ||
|
||
/** | ||
* Internal Action result stream that is emitted when an action is completed. | ||
* This is used as a method of returning the action result to the dispatcher | ||
* for the observable returned by the dispatch(...) call. | ||
* The dispatcher then asynchronously pushes the result from this stream onto the main action stream as a result. | ||
*/ | ||
@Injectable({ providedIn: 'root' }) | ||
export class InternalDispatchedActionResults | ||
extends Subject<ActionContext> | ||
implements OnDestroy | ||
{ | ||
ngOnDestroy(): void { | ||
// Complete the subject once the root injector is destroyed to ensure | ||
// there are no active subscribers that would receive events or perform | ||
// any actions after the application is destroyed. | ||
this.complete(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters