The Notifier service
Having the UI and the database in place, now it is time to implement the service that delivers the actual tasks for the notifier. Earlier in this chapter, we mentioned three tasks for the notifier: collect the news, rate and store them (in case they pass the threshold), and finally notify the user. The important feature for this service is that it should run periodically at specific times:
// src/app/notifier/notifier.service.ts import {Injectable} from '@angular/core'; import {CollectorService} from '../collector/collector.service'; import {RatingService} from '../rating/rating.service'; import {FirebaseListObservable, AngularFire} from 'angularfire2'; @Injectable() export class NotifierService { private cron = require('node-cron'); private collectorService; private ratingService; private angularFire; private task; constructor(cs: CollectorService, rs: RatingService, af: AngularFire) { this.collectorService = cs; this...