Skip to content

Commit

Permalink
Misc minor changes (#205)
Browse files Browse the repository at this point in the history
* refactor(providers): allow offline compilation

* chore(npm): automatically install typings on npm i
  • Loading branch information
vicb authored and jeffbcross committed Jun 20, 2016
1 parent 8193ebd commit 002d9ed
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 12 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"test": "npm run build; karma start",
"docs": "typedoc --out docs/api/ --module commonjs --mode modules --name AngularFire2 src",
"build": "rm -rf dist; tsc",
"build_npm": "rm -rf dist && ./node_modules/.bin/tsc -p tsconfig.publish.es5.json && ./node_modules/.bin/tsc -p tsconfig.publish.es6.json",
"build_npm": "rm -rf dist && tsc -p tsconfig.publish.es5.json && tsc -p tsconfig.publish.es6.json",
"postbuild_npm": "cp manual_typings/firebase3/firebase3.d.ts package.json README.md .npmignore dist/ && npm run rewrite_npm_package",
"rewrite_npm_package": "node --harmony_destructuring tools/rewrite-published-package.js",
"build_bundle": "cp -r src angularfire2 && tsc typings/main.d.ts angularfire2.ts --rootDir . --module system -t es5 --outFile dist/bundles/angularfire2.js --moduleResolution node --emitDecoratorMetadata --experimentalDecorators",
Expand Down
27 changes: 16 additions & 11 deletions src/angularfire2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,32 +31,37 @@ export class AngularFire {
}

export const COMMON_PROVIDERS: any[] = [
provide(FirebaseApp, {
useFactory: (config: FirebaseAppConfig) => {
return initializeApp(config);
},
deps: [FirebaseConfig]}),
// TODO: Deprecate
provide(FirebaseAuth, {
useExisting: AngularFireAuth
}),
{
provide: FirebaseApp,
useFactory: _getFirebase,
deps: [FirebaseConfig]
},
AngularFireAuth,
AngularFire,
FirebaseDatabase,
FirebaseDatabase
];

function _getFirebase(url:string): Firebase {
return new Firebase(url);
function _getFirebase(config: FirebaseAppConfig): firebase.app.App {
return initializeApp(config);
}

export const FIREBASE_PROVIDERS:any[] = [
COMMON_PROVIDERS,
provide(AuthBackend, {
useFactory: (app: firebase.app.App) => new FirebaseSdkAuthBackend(app, false),
{
provide: AuthBackend,
useFactory: _getAuthBackend,
deps: [FirebaseApp]
})
}
];

function _getAuthBackend(app: firebase.app.App): FirebaseSdkAuthBackend {
return new FirebaseSdkAuthBackend(app, false);
}

/**
* Used to define the default Firebase root location to be
* used throughout an application.
Expand Down

0 comments on commit 002d9ed

Please sign in to comment.