ing
This commit is contained in:
parent
d688911fe5
commit
600957820f
|
@ -8,12 +8,7 @@ import {
|
|||
Injector,
|
||||
} from '@angular/core';
|
||||
|
||||
import {
|
||||
StoreModule,
|
||||
Store,
|
||||
combineReducers,
|
||||
ReducerManager,
|
||||
} from '@ngrx/store';
|
||||
import { Store, StoreModule, ReducerManager, combineReducers } from '@ngrx/store';
|
||||
|
||||
import {
|
||||
_STORE,
|
||||
|
@ -23,37 +18,10 @@ import {
|
|||
|
||||
import { NgRxStoreSelect } from './service';
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
StoreModule,
|
||||
],
|
||||
providers: [
|
||||
NgRxStoreSelect,
|
||||
],
|
||||
})
|
||||
export class NgRxStoreModule {
|
||||
static forRoot(reducers: any): ModuleWithProviders {
|
||||
return {
|
||||
ngModule: NgRxStoreModule,
|
||||
providers: [
|
||||
{ provide: _STORE, useValue: reducers },
|
||||
],
|
||||
};
|
||||
}
|
||||
|
||||
static forFeature(featureName: string, reducers?: any): ModuleWithProviders {
|
||||
return {
|
||||
ngModule: NgRxStoreModule,
|
||||
providers: [
|
||||
{ provide: _STORE_FEATURE, useValue: { featureName, reducers } },
|
||||
],
|
||||
};
|
||||
}
|
||||
|
||||
@NgModule({})
|
||||
export class NgRxStoreRootModule {
|
||||
constructor(
|
||||
@Optional() @Inject(_STORE) reducers: any,
|
||||
@Optional() @Inject(_STORE_FEATURE) featureReducers: any,
|
||||
|
||||
reducerFactory: ReducerManager,
|
||||
store: Store<any>,
|
||||
parentInjector: Injector,
|
||||
|
@ -71,6 +39,19 @@ export class NgRxStoreModule {
|
|||
reducerFactory.addReducer(key, createReducer(inst));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@NgModule({})
|
||||
export class NgRStoreFeatureModule implements OnDestroy {
|
||||
constructor(
|
||||
@Optional() @Inject(_STORE_FEATURE) featureReducers: any,
|
||||
reducerFactory: ReducerManager,
|
||||
store: Store<any>,
|
||||
parentInjector: Injector,
|
||||
select: NgRxStoreSelect,
|
||||
) {
|
||||
select.connect(store);
|
||||
|
||||
if (featureReducers) {
|
||||
if (typeof featureReducers.key !== 'string') {
|
||||
|
@ -98,5 +79,36 @@ export class NgRxStoreModule {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
StoreModule,
|
||||
],
|
||||
providers: [
|
||||
NgRxStoreSelect
|
||||
],
|
||||
})
|
||||
export class NgRxStoreModule {
|
||||
static forRoot(reducers: any): ModuleWithProviders {
|
||||
return {
|
||||
ngModule: NgRxStoreRootModule,
|
||||
providers: [
|
||||
{ provide: _STORE, useValue: reducers },
|
||||
],
|
||||
};
|
||||
}
|
||||
|
||||
static forFeature(featureName: string, reducers?: any): ModuleWithProviders {
|
||||
return {
|
||||
ngModule: NgRStoreFeatureModule,
|
||||
providers: [
|
||||
{ provide: _STORE_FEATURE, useValue: { featureName, reducers } },
|
||||
],
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user