Skip to content

Instantly share code, notes, and snippets.

@kmaraz
Last active April 6, 2018 12:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kmaraz/232661ce513316ee25f21e87fcee0951 to your computer and use it in GitHub Desktop.
Save kmaraz/232661ce513316ee25f21e87fcee0951 to your computer and use it in GitHub Desktop.
export interface RegisterEffects { ngRegisterEffects(): void; }
export const EFFECTS_CLASS = new InjectionToken<RegisterEffects[]>('EFFECTS_CLASS');
export function EffectsProvider<T extends RegisterEffects>(
effectsClass: Type<T>): ClassProvider {
return {
multi: true,
provide: EFFECTS_CLASS,
useClass: effectsClass
};
}
export function getEffectProviders() {
return [
// For each module we need to get its effects class
// and return it as a injectable. Also in the `ngDoBootstrap`
// wee need to call its method `ngRegisterEffects`.
EffectsProvider(EventsEffects)
];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment