Skip to content

Commit 02431b4

Browse files
authored
fix(component-store): use asapScheduler to schedule lifecycle hooks check (#3580)
Closes #3573
1 parent 2c0f630 commit 02431b4

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

modules/component-store/spec/component-store.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ import {
3737
Injector,
3838
Provider,
3939
} from '@angular/core';
40-
import { fakeAsync, tick } from '@angular/core/testing';
40+
import { fakeAsync, flushMicrotasks } from '@angular/core/testing';
4141

4242
describe('Component Store', () => {
4343
describe('initialization', () => {
@@ -1651,7 +1651,7 @@ describe('Component Store', () => {
16511651

16521652
const store = state.injector.get(LifecycleStore);
16531653

1654-
tick(0);
1654+
flushMicrotasks();
16551655
expect(store.ngrxOnStoreInit).toBeDefined();
16561656
expect(store['ɵhasProvider']).toBeTruthy();
16571657
expect(console.warn).not.toHaveBeenCalled();
@@ -1666,7 +1666,7 @@ describe('Component Store', () => {
16661666

16671667
const store = state.injector.get(NonProviderStore);
16681668

1669-
tick(0);
1669+
flushMicrotasks();
16701670
expect(store.ngrxOnStoreInit).toBeDefined();
16711671
expect(store['ɵhasProvider']).toBeFalsy();
16721672
expect(console.warn).toHaveBeenCalled();

modules/component-store/src/component-store.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99
Subject,
1010
queueScheduler,
1111
scheduled,
12-
asyncScheduler,
12+
asapScheduler,
1313
EMPTY,
1414
} from 'rxjs';
1515
import {
@@ -322,7 +322,7 @@ export class ComponentStore<T extends object> implements OnDestroy {
322322
* but not used with provideComponentStore()
323323
*/
324324
private checkProviderForHooks() {
325-
asyncScheduler.schedule(() => {
325+
asapScheduler.schedule(() => {
326326
if (
327327
isDevMode() &&
328328
(isOnStoreInitDefined(this) || isOnStateInitDefined(this)) &&

0 commit comments

Comments
 (0)