DI keeps injecting empty object?

I have a service:

import {Injectable} from '@angular/core';
import {Subject} from "rxjs";

export class AuthTracker {
  public loginNotifier: Subject<boolean>;

When I import into my component, the authTracker param is just an empty object (no “loginNotifier” property):

import {NavController} from "ionic-angular";
import {AuthTracker} from '../../providers/authentication/auth-tracker';
import {Injectable, Component} from "@angular/core";
import {LoginPage} from "./login";
import {HelloIonicPage} from "../../pages/hello-ionic/hello-ionic";

  template: ''
export class DispatchPage {
  constructor(nav: NavController, authTracker: AuthTracker) {
    let logsub = (loggedin) => {
      if (loggedin) {
      } else {

I have the AuthTracker token provided in bootstrap:


No errors coming up. Please, what am I missing?

Grr…I finally figured it out. For anyone else who is trying to use the great code sample here make sure you actually assign a value to the loginNotifier property…

I just needed to add this.loginNotifier = new Subject<boolean>(); in the constructor of AuthTracker.

Sorry, I semi-deliberately left that out because there are many different choices you can make there depending on how you want things to behave. Generally, I want anybody subscribing to the authentication tracker to get only the current status, and to always have that status be available, so I tend to use new ReplaySubject<boolean>(1).

Thanks @rapropos. I feel like I’m going to make a lot of mistakes like this before I get my head wrapped around rxjs.

Thanks for that other code you originally posted that showed me the loginNotifier pattern. Best solution I’ve discovered so far for that problem.