Skip to content

Instantly share code, notes, and snippets.

@kmaraz
Last active April 10, 2018 21:52
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/6654ac7354deee883d2993febdff5b8c to your computer and use it in GitHub Desktop.
Save kmaraz/6654ac7354deee883d2993febdff5b8c to your computer and use it in GitHub Desktop.
// InjectionToken is a solution when choosing a provider token for non-class dependencies
// In this case we are redistering the reducers for this particular module
export const EVENTS_REDUCER_TOKEN = new InjectionToken<ActionReducerMap<fromEvents.State>>('Events');
// Map of our reducers
export function getReducers(): ActionReducerMap<fromEvents.State> {
return {
events: fromEvents.eventsReducer
};
}
@NgModule({
declarations: [EventsComponent],
entryComponents: [EventsComponent],
imports: [StoreModule.forFeature('Events', EVENTS_REDUCER_TOKEN)],
providers: [{
provide: EVENTS_REDUCER_TOKEN,
useFactory: getReducers
},
// Effects are in the hybrid app initialized differently than in the pure Angular app.
EventsEffects]
})
export class EventsModule { }
const ngModule = module('ng2.modules', []);
// If we want to use the entry component in the AngularJs part of the application, we need to downgrade it.
ngModule.directive('events', downgradeComponent({ component: EventsComponent }) as angular.IDirectiveFactory);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment