Commit cadfd664 authored by Ryan Diehl's avatar Ryan Diehl

code review feedback

parent d05f9165
Pipeline #90419 passed with stages
in 4 minutes and 20 seconds
export * from './lib/loading-events';
export * from './lib/loading-events.module';
export { LoadingEvents } from './lib/loading-events';
export { LoadingEventsModule } from './lib/loading-events.module';
......@@ -16,10 +16,8 @@ export class LoadingEvents {
if (this.isAppReady) {
return;
}
const bubbles = true;
const cancelable = false;
this.log.debug('appready event triggered');
this.doc.dispatchEvent(this.createEvent('appready', bubbles, cancelable));
this.doc.dispatchEvent(this.createEvent('appready', true, false));
this.isAppReady = true;
}
......
# utils-logger
# @psu/utils/logger
This library was generated with [Nx](https://nx.dev).
`Logger` is a simple facade around console logging. In the future, if we are
able to add some type of RESTful logging (Splunk for example), it would go here.
## Usage
1. Define logger options in your environment files
```typescript
// environment.ts
export function loggerOptions(): Options {
return { level: Level.LOG };
}
export const environment = {
production: false,
loggerOptions
};
```
2. Import LoggerModule into your AppModule
```typescript
imports: [LoggerModule.forRoot(environment.loggerOptions)];
```
3. Inject `Logger` and log stuff
## Running unit tests
......
export * from './lib/log-level.model';
export * from './lib/logger.module';
export * from './lib/logger.service';
export { Level } from './lib/log-level.model';
export { LoggerModule } from './lib/logger.module';
export { Logger } from './lib/logger.service';
......@@ -11,7 +11,7 @@ export class Options {
level: Level;
}
// For browsers that don't implement the debug method, log will be used instead. Fixes #62.
// For browsers that don't implement the debug method, log will be used instead.
const CONSOLE_DEBUG_METHOD = console['debug'] ? 'debug' : 'log';
const DEFAULT_OPTIONS: Options = {
......
......@@ -5,9 +5,9 @@
"@angular/common": "^8.0.0",
"@angular/core": "^8.0.0",
"@angular/cdk": "^8.2.3",
"ngx-cookie": ">=4.1.2",
"ngx-cookie": "^4.1.2",
"ramda": "^0.27.0",
"short-uuid": ">=3.1.1"
"short-uuid": "^3.1.1"
},
"private": false,
"repository": {
......
# utils-properties
# @psu/utils/properties
This library was generated with [Nx](https://nx.dev).
This library handles loading application properties asyncronously.
Typical Angular documentation shows the use of `environment.ts` and `environment.prod.ts` to
store application properties. However, that strategy means that the properties are compile-time
dependencies - so in order to change a property at runtime, you need to re-compile the whole app.
This library is the first piece of supporting property changes at runtime. `PropetiesService` will
load the property file via HTTP, and exposes a `Promise<T>` to work with Angular's `APP_INITIALIZER`.
## Usage
1. Import PropertiesModule into your AppModule
2. Define an interface(s) that describes the shape of your application properties.
```typescript
import { SecurityConfig } from '@psu/security';
export interface MyAppProperties {
myAppConfig: MyAppConfig;
security: SecurityConfig;
}
export interface MyAppConfig {
someUrl: string;
doStuff: boolean;
}
```
3. Setup an [APP_INITIALIZER](https://angular.io/api/core/APP_INITIALIZER)
to load properties and delay loading of the application by returning a Promise
```typescript
// inside AppMdoule's providers array:
{
provide: MY_APP_CONFIG, // provide your app's token
useValue: {} // provide default values for the token
},
{ provide: SECURITY_CONFIG, useValue: {} },
{
provide: APP_INITIALIZER,
useFactory: initProperties,
multi: true,
deps: [
PropertiesService,
MY_APP_CONFIG, // your app config injection token
SECURITY_CONFIG
]
}
// Define the initProperties function
export function initProperties(
propertiesService: PropertiesService<MyAppProperties>,
myAppConfig: MyAppConfig,
securityConfig: SecurityConfig): () => Promise<MyAppProperties> {
return () => propertiesService.load('my-app').then(props => {
// populate injection tokens with values from property file
// "props" is of type MyAppProperties
Object.assign(myAppConfig, p.myAppConfig);
Object.assign(securityConfig, p.security);
});
}
```
## Running unit tests
......
export * from './lib/properties.config';
export * from './lib/properties.module';
export * from './lib/properties.service';
export { PropertiesConfig, PROPERTIES_CONFIG } from './lib/properties.config';
export { PropertiesModule } from './lib/properties.module';
export { PropertiesService } from './lib/properties.service';
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment