Instantiate EventListener (inside Service) in Ionic2 App only once

I want to add an Event Listener to my Ionic2 project, but only once of course. How to make sure it is only instantiated once. I came up with this, but it feels wrong. We load all services in app.module.ts. I construct/instantiate this service in our BackEnd Service, it gets called many times.

import {Injectable} from "@angular/core";

export class AppPausedService {

    private appPaused = false;
    private alreadyInstantiated = false;

    constructor() {

        if (!this.alreadyInstantiated) {
            this.alreadyInstantiated = true;

            document.addEventListener("pause", () => {
                this.appPaused = true;
            }, false);

            document.addEventListener("resume", () => {
                this.appPaused = false;
            }, false);

    isPaused () {
        return this.appPaused;


This concept seems very sketchy to me at a higher level, but…

Services provided in a module are injected in the app root injector, so it will be available everywhere. So as long as you don’t try to reprovide it anywhere the constructor will only ever be called once anyway.

Although I find it concerning that you say you construct it in another service…Why would you do that?

In another service (indeed) I just import above service and use the isPaused method. Ny debugging seconds your understanding of ionics app root injector.