Last active
April 10, 2018 21:52
-
-
Save kmaraz/6654ac7354deee883d2993febdff5b8c to your computer and use it in GitHub Desktop.
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
// 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