Skip to content

Commit

Permalink
fix(BlockUIContent): Fully clean up on destroy
Browse files Browse the repository at this point in the history
  • Loading branch information
kuuurt13 committed Apr 30, 2020
1 parent 240be3a commit 3cddef2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export class BlockUIContentComponent implements OnInit, AfterViewInit, AfterView
private blockUI: BlockUIInstanceService,
private resolver: ComponentFactoryResolver,
private changeDetectionRef: ChangeDetectorRef
) {}
) { }

ngOnInit() {
this.settings = this.blockUI.getSettings();
Expand Down Expand Up @@ -199,5 +199,6 @@ export class BlockUIContentComponent implements OnInit, AfterViewInit, AfterView
ngOnDestroy() {
this.resetState();
this.onUnsubscribe(this.name);
this.blockUI.clearInstance(this.name);
}
}
6 changes: 5 additions & 1 deletion lib/services/block-ui-instance.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { BlockUIEvent } from '../models/block-ui-event.model';
export class BlockUIInstanceService {
blockUISettings: BlockUISettings | any = {};
blockUIInstances: any = {};
private blockUISubject: ReplaySubject<any> = new ReplaySubject();
private blockUISubject: ReplaySubject<any> = new ReplaySubject(1);
private blockUIObservable: Observable<any> = this.blockUISubject.asObservable();

constructor() {
Expand Down Expand Up @@ -47,6 +47,10 @@ export class BlockUIInstanceService {
return this.blockUIObservable;
}

clearInstance(instanceName: string) {
this.dispatch(this.blockUISubject, BlockUIActions.RESET, instanceName);
}

private blockUIMiddleware({ action, name }: BlockUIEvent): void {
let isActive: boolean = null;

Expand Down

0 comments on commit 3cddef2

Please sign in to comment.