Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(Devtools): Ensure Store is loaded eagerly #801

Merged
merged 1 commit into from
Feb 9, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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