refractor: core module (#289)
* Shift services into their own folders. * Add comments. Fixes #288
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
/**
|
||||
* Alert model.
|
||||
*/
|
||||
export interface Alert {
|
||||
type: string;
|
||||
message: string;
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
import { TestBed, inject } from '@angular/core/testing';
|
||||
|
||||
import { AlertService } from './alert.service';
|
||||
|
||||
describe('AlertService', () => {
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
providers: [AlertService]
|
||||
});
|
||||
});
|
||||
|
||||
it('should be created', inject([AlertService], (service: AlertService) => {
|
||||
expect(service).toBeTruthy();
|
||||
}));
|
||||
});
|
||||
@@ -0,0 +1,33 @@
|
||||
/** Angular Imports */
|
||||
import { Injectable, EventEmitter } from '@angular/core';
|
||||
|
||||
/** Custom Model */
|
||||
import { Alert } from './alert.model';
|
||||
|
||||
/**
|
||||
* Alert service.
|
||||
*/
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class AlertService {
|
||||
|
||||
/** Alert event. */
|
||||
public alertEvent: EventEmitter<Alert>;
|
||||
|
||||
/**
|
||||
* Initializes alert event.
|
||||
*/
|
||||
constructor() {
|
||||
this.alertEvent = new EventEmitter();
|
||||
}
|
||||
|
||||
/**
|
||||
* Emits an alert event.
|
||||
* @param {Alert} alertEvent Alert event.
|
||||
*/
|
||||
alert(alertEvent: Alert) {
|
||||
this.alertEvent.emit(alertEvent);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user