@ddng/library
v0.0.2
Published
```typescript import {BrowserModule} from '@angular/platform-browser'; import {NgModule} from '@angular/core';
Downloads
1
Readme
Ddng Library
AppModule
import {BrowserModule} from '@angular/platform-browser';
import {NgModule} from '@angular/core';
import {AppComponent} from './app.component';
import {
AuthService, authServiceFactory,
CoreModule,
IAppState,
LayoutModule,
loadState,
rootReducer,
saveState,
SharedModule
} from '@ddng/library';
import {RoutesModule} from './routes.module';
import {HttpClient, HttpClientModule} from '@angular/common/http';
import {TranslateHttpLoader} from '@ngx-translate/http-loader';
import {TranslateLoader, TranslateModule} from '@ngx-translate/core';
import {TabsModule} from 'ngx-bootstrap';
import {applyMiddleware, createStore, Store} from 'redux';
import {createLogger} from 'redux-logger';
import {NgRedux} from '@angular-redux/store';
// https://github.com/ocombe/ng2-translate/issues/218
export function createTranslateLoader(http: HttpClient) {
return new TranslateHttpLoader(http, './assets/i18n/', '.json');
}
const persistedState = loadState();
export const store: Store<IAppState> = createStore(
rootReducer
, persistedState
, applyMiddleware(createLogger())
);
store.subscribe(() => {
saveState(store.getState());
});
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
RoutesModule,
HttpClientModule,
CoreModule,
SharedModule,
LayoutModule,
TranslateModule.forRoot({
loader: {
provide: TranslateLoader,
useFactory: (createTranslateLoader),
deps: [HttpClient]
}
}),
TabsModule.forRoot()
],
providers: [
{
provide: AuthService,
useFactory: (http: HttpClient, ngRedux: NgRedux<IAppState>) => {
return authServiceFactory(http, ngRedux, {
loginUrl: '/v1/api/auth',
fetchUserUrl: '/v1/api/auth',
registerUrl: '/v1/api/auth/register',
logoutUrl: '/v1/api/auth',
});
},
deps: [HttpClient, NgRedux]
}
],
bootstrap: [AppComponent]
})
export class AppModule {
constructor(ngRedux: NgRedux<IAppState>) {
ngRedux.provideStore(store);
}
}