Skip to content

Commit

Permalink
fix(Devtools): Ensure Store is loaded eagerly (#801)
Browse files Browse the repository at this point in the history
Closes #624,#741
  • Loading branch information
brandonroberts authored and MikeRyanDev committed Feb 9, 2018
1 parent 0e5d209 commit ecf1ebf
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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
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 ecf1ebf

Please sign in to comment.