本文整理匯總了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( () => {})
]
});
});