Created
April 13, 2016 19:48
-
-
Save jmreidy/3c731e409677e168a500c9b34cc5d0a4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { OpaqueToken } from 'angular2/core'; | |
export interface IConfig { | |
fbRef: string | |
}; | |
export const CONFIG = { | |
fbRef: "" | |
}; | |
export const IConfig = new OpaqueToken('app.config'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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