-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
revert(Effects): dispatch init feature effects action on init #1305
During a prod build the contructor name of an effect gets magnled, therefore this implementation can't be used.
- Loading branch information
1 parent
6311b89
commit e9cc9ae
Showing
4 changed files
with
13 additions
and
111 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,20 @@ | ||
import { NgModule, Inject, Optional } from '@angular/core'; | ||
import { StoreRootModule, StoreFeatureModule, Store } from '@ngrx/store'; | ||
import { StoreRootModule, StoreFeatureModule } from '@ngrx/store'; | ||
import { EffectsRootModule } from './effects_root_module'; | ||
import { FEATURE_EFFECTS } from './tokens'; | ||
import { getSourceForInstance } from './effects_metadata'; | ||
|
||
export const UPDATE_EFFECTS = '@ngrx/effects/update-effects'; | ||
export type UpdateEffects = { | ||
type: typeof UPDATE_EFFECTS; | ||
effects: string[]; | ||
}; | ||
|
||
@NgModule({}) | ||
export class EffectsFeatureModule { | ||
constructor( | ||
root: EffectsRootModule, | ||
store: Store<any>, | ||
@Inject(FEATURE_EFFECTS) effectSourceGroups: any[][], | ||
@Optional() storeRootModule: StoreRootModule, | ||
@Optional() storeFeatureModule: StoreFeatureModule | ||
) { | ||
effectSourceGroups.forEach(group => { | ||
let effectSourceNames: string[] = []; | ||
|
||
group.forEach(effectSourceInstance => { | ||
root.addEffects(effectSourceInstance); | ||
|
||
const { constructor } = getSourceForInstance(effectSourceInstance); | ||
effectSourceNames.push(constructor.name); | ||
}); | ||
|
||
store.dispatch(<UpdateEffects>{ | ||
type: UPDATE_EFFECTS, | ||
effects: effectSourceNames, | ||
}); | ||
}); | ||
effectSourceGroups.forEach(group => | ||
group.forEach(effectSourceInstance => | ||
root.addEffects(effectSourceInstance) | ||
) | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters