ing
This commit is contained in:
parent
d688911fe5
commit
600957820f
|
@ -8,12 +8,7 @@ import {
|
||||||
Injector,
|
Injector,
|
||||||
} from '@angular/core';
|
} from '@angular/core';
|
||||||
|
|
||||||
import {
|
import { Store, StoreModule, ReducerManager, combineReducers } from '@ngrx/store';
|
||||||
StoreModule,
|
|
||||||
Store,
|
|
||||||
combineReducers,
|
|
||||||
ReducerManager,
|
|
||||||
} from '@ngrx/store';
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
_STORE,
|
_STORE,
|
||||||
|
@ -23,37 +18,10 @@ import {
|
||||||
|
|
||||||
import { NgRxStoreSelect } from './service';
|
import { NgRxStoreSelect } from './service';
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({})
|
||||||
imports: [
|
export class NgRxStoreRootModule {
|
||||||
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 } },
|
|
||||||
],
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
@Optional() @Inject(_STORE) reducers: any,
|
@Optional() @Inject(_STORE) reducers: any,
|
||||||
@Optional() @Inject(_STORE_FEATURE) featureReducers: any,
|
|
||||||
|
|
||||||
reducerFactory: ReducerManager,
|
reducerFactory: ReducerManager,
|
||||||
store: Store<any>,
|
store: Store<any>,
|
||||||
parentInjector: Injector,
|
parentInjector: Injector,
|
||||||
|
@ -71,6 +39,19 @@ export class NgRxStoreModule {
|
||||||
reducerFactory.addReducer(key, createReducer(inst));
|
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 (featureReducers) {
|
||||||
if (typeof featureReducers.key !== 'string') {
|
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