Skip to content

fix(providers): remove DEFAULT_ DEFAULT_FIREBASE_REF and DEFAULT_FIRE… #30

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 29, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,27 +22,27 @@ import {FIREBASE_PROVIDERS} from 'angularfire2';
bootstrap(App, FIREBASE_PROVIDERS);
```

### DEFAULT_FIREBASE_REF
### FirebaseRef

Injectable symbol to create a Firebase reference based on
the url provided by `DEFAULT_FIREBASE`.
the url provided by `FirebaseUrl`.

Type: `Firebase`

Usage:

```
import {Inject} from 'angular2/core';
import {DEFAULT_FIREBASE_REF} from 'angularfire2';
import {FirebaseRef} from 'angularfire2';
...
class MyComponent {
constructor(@Inject(DEFAULT_FIREBASE_REF) ref:Firebase) {
constructor(@Inject(FirebaseRef) ref:Firebase) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

definitely worth considering the ergonomics here - @Inject(FirebaseRef) ref:Firebase vs ref:Firebase vs ref:FirebaseRef

ref.on('value', this.doSomething);
}
}
```

### DEFAULT_FIREBASE
### FirebaseUrl

URL for the app's default Firebase database.

Expand All @@ -53,11 +53,11 @@ Usage:
```
import {App} from './app';
import {bootstrap, provide} from 'angular2/core';
import {DEFAULT_FIREBASE, FIREBASE_PROVIDERS} from 'angularfire2';
import {FirebaseUrl, FIREBASE_PROVIDERS} from 'angularfire2';

bootstrap(App, [
FIREBASE_PROVIDERS,
provide(DEFAULT_FIREBASE, {
provide(FirebaseUrl, {
useValue: 'https://my.firebaseio.com'
})
]);
Expand All @@ -81,7 +81,7 @@ import {FirebaseList} from 'angularfire2';
providers: [
FirebaseList({
token: Question, // Token used to inject in the constructor
path: '/questions', // Will append to the DEFAULT_FIREBASE if relative
path: '/questions', // Will append to the FirebaseUrl if relative
}),
// Passing just a string will make that the path AND the token used with @Inject
FirebaseList('/topics')
Expand Down
10 changes: 5 additions & 5 deletions src/angularfire.spec.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import {describe,it,beforeEach} from 'angular2/testing';
import {Injector, provide} from 'angular2/core';
import {FIREBASE_PROVIDERS, DEFAULT_FIREBASE, DEFAULT_FIREBASE_REF} from './angularfire';
import {FIREBASE_PROVIDERS, FirebaseUrl, FirebaseRef} from './angularfire';

describe('angularfire', () => {
describe('DEFAULT_FIREBASE_REF', () => {
it('should provide a FirebaseRef for the DEFAULT_FIREBASE_REF binding', () => {
describe('FIREBASE_REF', () => {
it('should provide a FirebaseRef for the FIREBASE_REF binding', () => {
var injector = Injector.resolveAndCreate([
provide(DEFAULT_FIREBASE, {
provide(FirebaseUrl, {
useValue: 'https://ng2-forum-demo.firebaseio.com'
}),
FIREBASE_PROVIDERS
]);
expect(typeof injector.get(DEFAULT_FIREBASE_REF).on).toBe('function');
expect(typeof injector.get(FirebaseRef).on).toBe('function');
})
});
});
8 changes: 4 additions & 4 deletions src/angularfire.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import {OpaqueToken, provide} from 'angular2/core';
import * as Firebase from 'firebase';

export const DEFAULT_FIREBASE = new OpaqueToken('DEFAULT_FIREBASE');
export const DEFAULT_FIREBASE_REF = new OpaqueToken('DEFAULT_FIREBASE_REF')
export const FirebaseUrl = new OpaqueToken('FirebaseUrl');
export const FirebaseRef = new OpaqueToken('FirebaseRef');

export const FIREBASE_PROVIDERS:any[] = [
provide(DEFAULT_FIREBASE_REF, {
provide(FirebaseRef, {
useFactory: (url:string) => new Firebase(url),
deps: [DEFAULT_FIREBASE]})
deps: [FirebaseUrl]})
];

export {FirebaseList, FirebaseListConfig} from './providers/firebase_list';
Expand Down
6 changes: 3 additions & 3 deletions src/providers/firebase_list.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {beforeEach, fit, inject, it, describe, expect, TestComponentBuilder} fro
import * as Firebase from 'firebase';

import {FirebaseList, FirebaseListFactory, onChildAdded, onChildMoved} from './firebase_list';
import {DEFAULT_FIREBASE, FirebaseObservable} from '../angularfire';
import {FirebaseUrl, FirebaseObservable} from '../angularfire';

enableProdMode();

Expand Down Expand Up @@ -40,7 +40,7 @@ const sharedTemplate = `
token: Todo,
path: '/todos'
}),
provide(DEFAULT_FIREBASE, {
provide(FirebaseUrl, {
useValue: rootFirebase
})
]
Expand All @@ -59,7 +59,7 @@ class MyComponent {
providers: [
FirebaseList('/posts'),
FirebaseList('/todos'),
provide(DEFAULT_FIREBASE, {
provide(FirebaseUrl, {
useValue: rootFirebase
})
]
Expand Down
4 changes: 2 additions & 2 deletions src/providers/firebase_list.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {Provider} from 'angular2/core';
import {DEFAULT_FIREBASE} from '../angularfire';
import {FirebaseUrl} from '../angularfire';
import {Observer} from 'rxjs/Observer';
import {FirebaseObservable} from '../utils/firebase_observable';
import {absolutePathResolver} from '../utils/absolute_path_resolver';
Expand All @@ -13,7 +13,7 @@ export function FirebaseList (config?:FirebaseListConfig|string):Provider {
var normalConfig = normalizeConfig(config);
return new Provider(normalConfig.token, {
useFactory: (defaultFirebase:string) => FirebaseListFactory(absolutePathResolver(defaultFirebase, normalConfig.path)),
deps: [DEFAULT_FIREBASE]
deps: [FirebaseUrl]
})
}

Expand Down
4 changes: 2 additions & 2 deletions test/e2e/firebase_list/firebase_list_example.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {Component, Inject, provide} from 'angular2/core';
import {bootstrap} from 'angular2/platform/browser';
import {DEFAULT_FIREBASE, FirebaseList, FirebaseObservable} from 'angularfire2';
import {FIREBASE_URL, FirebaseList, FirebaseObservable} from 'angularfire2';
// var Firebase = require('firebase');
import Firebase from 'firebase';
const rootFirebase = 'https://answers-mobile.firebaseio.com/';
Expand All @@ -27,6 +27,6 @@ class App {
}

bootstrap(App, [
provide(DEFAULT_FIREBASE, {
provide(FIREBASE_URL, {
useValue: rootFirebase
})]);