Skip to content

Commit

Permalink
fix(Devtools): Ensure Store is loaded eagerly
Browse files Browse the repository at this point in the history
Closes #624,#741
  • Loading branch information
brandonroberts committed Feb 9, 2018
1 parent 91542dd commit 03d6dbb
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 3 deletions.
41 changes: 41 additions & 0 deletions modules/store-devtools/spec/integration.spec.ts
@@ -0,0 +1,41 @@
import { NgModule } from '@angular/core';
import { TestBed } from '@angular/core/testing';
import { StoreModule, Store, ActionsSubject } from '@ngrx/store';
import { StoreDevtoolsModule, StoreDevtools } from '@ngrx/store-devtools';

describe('Devtools Integration', () => {
let store: Store<any>;

@NgModule({
imports: [StoreModule.forFeature('a', (state: any, action: any) => state)],
})
class EagerFeatureModule {}

@NgModule({
imports: [
StoreModule.forRoot({}),
EagerFeatureModule,
StoreDevtoolsModule.instrument(),
],
})
class RootModule {}

beforeEach(() => {
TestBed.configureTestingModule({
imports: [RootModule],
});
});

it('should load the store eagerly', () => {
let error = false;

try {
let store = TestBed.get(Store);
store.subscribe();
} catch (e) {
error = true;
}

expect(error).toBeFalsy();
});
});
8 changes: 5 additions & 3 deletions modules/store/src/store_module.ts
Expand Up @@ -41,14 +41,15 @@ import {
ScannedActionsSubject,
} from './scanned_actions_subject';
import { STATE_PROVIDERS } from './state';
import { STORE_PROVIDERS } from './store';
import { STORE_PROVIDERS, Store } from './store';

@NgModule({})
export class StoreRootModule {
constructor(
actions$: ActionsSubject,
reducer$: ReducerObservable,
scannedActions$: ScannedActionsSubject
scannedActions$: ScannedActionsSubject,
store: Store<any>
) {}
}

Expand All @@ -57,7 +58,8 @@ export class StoreFeatureModule implements OnDestroy {
constructor(
@Inject(STORE_FEATURES) private features: StoreFeature<any, any>[],
@Inject(FEATURE_REDUCERS) private featureReducers: ActionReducerMap<any>[],
private reducerManager: ReducerManager
private reducerManager: ReducerManager,
root: StoreRootModule
) {
features
.map((feature, index) => {
Expand Down

0 comments on commit 03d6dbb

Please sign in to comment.