Skip to content

Latest commit

 

History

History
89 lines (65 loc) · 1.24 KB

README.md

File metadata and controls

89 lines (65 loc) · 1.24 KB

Dynamic modules configuration for Angular Redux

Works with async modules too.

How to use:

App module:

import { StoreModule } from 'angular-redux-dynamic-modules';

@NgModule({
	declarations: [
		AppComponent
	],
	imports: [
		...
		StoreModule,
		...
		UserModule,
		HRModule,
	],
	bootstrap: [AppComponent]
})
export class AppModule { }

User Module (for example):

import { StoreConfigService } from 'angular-redux-dynamic-modules';


@NgModule({
	imports: [
		CommonModule,
	],
	providers: [Actions, UserService, Epics],
})
export class UserModule {
	constructor(
		storeConfig: StoreConfigService,
		epics: Epics
	) {

		// Register State
		storeConfig.addModule(
			'User',
			InitialState,
			reducer,
			[epics]
		);

	}

}

Dispatching Actions:

import { Dispatcher } from 'angular-redux-dynamic-modules';
import * as user from '@modules/user';
import * as hr from '@modules/hr';

export class MainComponent implements OnInit {

	constructor(
		private store: Dispatcher<hr.PublicAction | user.PublicAction>
	) { }
	
	ngOnInit() {
		this.store.dispatch({
			type: hr.ActionType.LoadList,
			filterName: '',
			filterSurname: ''
		});
	}

}

Also please check out: Example App