Skip to content

Instantly share code, notes, and snippets.

@jmreidy
Created April 13, 2016 19:48
Show Gist options
  • Save jmreidy/3c731e409677e168a500c9b34cc5d0a4 to your computer and use it in GitHub Desktop.
Save jmreidy/3c731e409677e168a500c9b34cc5d0a4 to your computer and use it in GitHub Desktop.
import { OpaqueToken } from 'angular2/core';
export interface IConfig {
fbRef: string
};
export const CONFIG = {
fbRef: ""
};
export const IConfig = new OpaqueToken('app.config');
import { Inject, Injectable, OpaqueToken } from 'angular2/core';
import * as Firebase from 'firebase';
import { IConfig } from '../lib/config';
export interface IFirebaseService {
ref: Firebase;
}
export const IFirebaseService = new OpaqueToken('FirebaseService');
@Injectable()
export class FirebaseService {
ref: Firebase;
constructor (@Inject(IConfig) _config:IConfig) {
this.ref = new Firebase(_config.fbRef);
}
}
import { Inject, Injectable } from 'angular2/core';
import { IFirebaseService } from '../lib/firebase.service';
@Injectable()
export class SchedulerService {
private schedulesRef:Firebase;
constructor(@Inject(IFirebaseService) fbService:IFirebaseService) {
this.schedulesRef = fbService.ref.child('schedules');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment