services/timer-service.js

/**
 * Service for tracking time on the base of the factory.
 * You can create multiple services using one factory
 *
 * @module timerService
 * @see https://docs.angularjs.org/api/ng/type/angular.Module#service
 */
angular.module('tgaApp').service('timerService', ['Timer',
  function timerService(Timer) {
    /**
     * Service-level Timer object.
     * @type {Timer}
     */
    this.timer = new Timer();

    /**
     * Proxy for {@link Timer#set} on {@link module:timerService.timer}
     * @method
     */
    this.set = this.timer.set;

    /**
     * Proxy for {@link Timer#reset} on {@link module:timerService.timer}
     * @method
     */
    this.reset = this.timer.reset;

    /**
     * Proxy for {@link Timer#stop} on {@link module:timerService.timer}
     * @method
     */
    this.stop = this.timer.stop;

    /**
     * Proxy for {@link Timer#start} on {@link module:timerService.timer}
     * @method
     */
    this.start = this.timer.start;

    /**
     * Proxy for {@link Timer#percentComplete} on {@link module:timerService.timer}
     * @return {number}
     */
    this.getPercentComplete = () => this.timer.percentComplete;
  },
]);