本文整理汇总了TypeScript中@ngrx/store.StoreModule.provideStore方法的典型用法代码示例。如果您正苦于以下问题:TypeScript StoreModule.provideStore方法的具体用法?TypeScript StoreModule.provideStore怎么用?TypeScript StoreModule.provideStore使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类@ngrx/store.StoreModule
的用法示例。
在下文中一共展示了StoreModule.provideStore方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: provideConsoleTarget
const testModuleConfig = (languages?: Array<ILang>) => {
let providers = [
provideConsoleTarget(LogLevel.Debug),
{ provide: LanguageViewHelper, useValue: null }
];
if (languages) {
providers.push({
provide: Languages,
useValue: languages
});
}
TestBed.configureTestingModule({
imports: [
CoreModule.forRoot([
{ provide: WindowService, useValue: window },
{ provide: ConsoleService, useValue: console }
]),
SharedModule,
RouterTestingModule,
AnalyticsModule,
MultilingualModule,
StoreModule.provideStore({ i18n: reducer })
],
declarations: [TestComponent],
providers
});
TestBed.compileComponents();
};
示例2:
const testModuleConfig = (options?: any) => {
let langProvider = [];
if (options.languages) {
langProvider.push({
provide: Languages,
useValue: options.languages
});
}
TestBed.configureTestingModule({
imports: [
CoreModule.forRoot([
{ provide: WindowService, useValue: window },
{ provide: ConsoleService, useValue: console }
]),
Angulartics2Module.forRoot([
Angulartics2Segment
]),
StoreModule.provideStore({ i18n: reducer }),
EffectsModule.run(MultilingualEffects),
RouterTestingModule
],
providers: [
TEST_CORE_PROVIDERS(options),
TEST_MULTILINGUAL_PROVIDERS(),
langProvider
]
});
TestBed.compileComponents();
};
示例3: Http
const testModuleConfig = () => {
TestBed.configureTestingModule({
imports: [
NoopAnimationsModule,
CoreModule,
RouterTestingModule,
AnalyticsModule,
MultilingualModule,
StoreModule.provideStore({ home: homeReducer }),
EffectsModule.run(NameListEffects),
MdInputModule,
MdButtonModule
],
declarations: [ HomeComponent, TestComponent ],
providers: [
NameListService,
BaseRequestOptions,
MockBackend,
provideConsoleTarget(LogLevel.Debug),
{
provide: Http,
useFactory: function (backend: ConnectionBackend, defaultOptions: BaseRequestOptions) {
return new Http(backend, defaultOptions);
},
deps: [ MockBackend, BaseRequestOptions ]
}
]
});
};
示例4: Http
const testModuleConfig = () => {
TestBed.configureTestingModule({
imports: [
CoreModule,
SharedModule,
RouterTestingModule,
AnalyticsModule,
MultilingualModule,
StoreModule.provideStore({ sample: reducer }),
EffectsModule.run(SampleEffects)
],
declarations: [HomeComponent, TestComponent],
providers: [
LanguageProviders,
NameListService,
BaseRequestOptions,
MockBackend,
{
provide: Http, useFactory: function (backend: ConnectionBackend, defaultOptions: BaseRequestOptions) {
return new Http(backend, defaultOptions);
},
deps: [MockBackend, BaseRequestOptions]
}
]
});
};
示例5: beforeEach
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [StoreModule.provideStore({})],
declarations: [ ActivityWidgetComponent ]
})
.compileComponents();
}));
示例6: beforeEach
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [RegistrationPdfComponent],
imports: [StoreModule.provideStore({ employerStore: reducer }, {})]
})
.compileComponents();
}));
示例7: getTestBed
function createStore<T>(reducer: ActionReducer<T>, options: StoreDevtoolsConfig = {}): Fixture<T> {
TestBed.configureTestingModule({
imports: [
StoreModule.provideStore(reducer),
StoreDevtoolsModule.instrumentStore(options)
]
});
const testbed: TestBed = getTestBed();
const store: Store<T> = testbed.get(Store);
const devtools: StoreDevtools = testbed.get(StoreDevtools);
const state: State<T> = testbed.get(State);
let liftedValue: LiftedState;
let value: T;
const liftedStateSub = devtools.liftedState.subscribe(s => liftedValue = s);
const stateSub = devtools.state.subscribe(s => value = s);
const getState = (): T => value;
const getLiftedState = (): LiftedState => liftedValue;
const cleanup = () => {
liftedStateSub.unsubscribe();
stateSub.unsubscribe();
};
const replaceReducer = reducer => {
store.replaceReducer(reducer);
};
return { store, state, devtools, cleanup, getState, getLiftedState, replaceReducer };
}
示例8: beforeEach
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ AppComponent ],
imports: [ StoreModule.provideStore(rootReducer) ],
schemas: [NO_ERRORS_SCHEMA],
providers: [HomeActions]
})
.compileComponents(); // compile template and css
}));
示例9: appReducersGenerator
export function appReducersGenerator () {
return StoreModule.provideStore({
devices: devicesReducer,
locations: locationsReducer,
activities: activitiesReducer,
widgets: widgetsReducer,
roles: rolesReducer
});
}
示例10: beforeEach
beforeEach(() => {
TestBed.configureTestingModule({
providers: [ArticleService],
imports: [
// use empty reducer for now
StoreModule.provideStore( () => {})
]
});
});