-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d72623d
commit 1233a1c
Showing
12 changed files
with
128 additions
and
19 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,4 +25,4 @@ publish.sh | |
|
||
# auto-gen files | ||
src/compat/**/base.ts | ||
src/**/rxfire.ts | ||
src/**/rxfire.ts |
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9162,10 +9162,10 @@ run-parallel@^1.1.9: | |
dependencies: | ||
queue-microtask "^1.2.2" | ||
|
||
[email protected].cee1afe: | ||
version "6.0.0-canary.cee1afe" | ||
resolved "https://registry.yarnpkg.com/rxfire/-/rxfire-6.0.0-canary.cee1afe.tgz#212318f2ccc034c25581f079c51f0d952164b4db" | ||
integrity sha512-PySJryeUfnuMuYlC8U+X83PIe53G1s+OpQuzjjaMUQ3gc1z6aD4ZEWc/O3LzVQ3ywwO/X4AAO9hv4F0Q3+y79A== | ||
[email protected].92c6c26: | ||
version "6.0.0-canary.92c6c26" | ||
resolved "https://registry.yarnpkg.com/rxfire/-/rxfire-6.0.0-canary.92c6c26.tgz#de888ac0ec975eb7860b4cee54aa15df90b9fec0" | ||
integrity sha512-zqZZFTCFXqGNRIN/zciPVzylSw3drlkM3mojTZj4GALeUBtMI59/hmAEevbAxBQjNk4eiWj/4vFsPFJtzgT5qA== | ||
dependencies: | ||
tslib "^1.9.0 || ~2.1.0" | ||
|
||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import { NgModule, Optional, NgZone, InjectionToken, ModuleWithProviders } from '@angular/core'; | ||
import { FirebaseFirestore } from 'firebase/firestore/lite'; | ||
import { AuthInstances } from '@angular/fire/auth'; | ||
import { ɵmemoizeInstance, ɵgetDefaultInstanceOf, ɵAngularFireSchedulers } from '@angular/fire'; | ||
import { Firestore, FirestoreInstances, FIRESTORE_PROVIDER_NAME } from './lite'; | ||
import { FirebaseApps } from '@angular/fire/app'; | ||
|
||
export const PROVIDED_FIRESTORE_INSTANCES = new InjectionToken<Firestore[]>('angularfire2.firestore-lite-instances'); | ||
|
||
export function defaultFirestoreInstanceFactory(_: Firestore[]) { | ||
const defaultFirestore = ɵgetDefaultInstanceOf<FirebaseFirestore>(FIRESTORE_PROVIDER_NAME); | ||
return new Firestore(defaultFirestore); | ||
} | ||
|
||
export function firestoreInstanceFactory(fn: () => FirebaseFirestore) { | ||
return (zone: NgZone) => { | ||
const firestore = ɵmemoizeInstance<FirebaseFirestore>(fn, zone); | ||
return new Firestore(firestore); | ||
}; | ||
} | ||
|
||
const FIRESTORE_INSTANCES_PROVIDER = { | ||
provide: FirestoreInstances, | ||
deps: [ | ||
[new Optional(), PROVIDED_FIRESTORE_INSTANCES ], | ||
] | ||
}; | ||
|
||
const DEFAULT_FIRESTORE_INSTANCE_PROVIDER = { | ||
provide: Firestore, | ||
useFactory: defaultFirestoreInstanceFactory, | ||
deps: [ | ||
NgZone, | ||
[new Optional(), PROVIDED_FIRESTORE_INSTANCES ], | ||
] | ||
}; | ||
|
||
@NgModule({ | ||
providers: [ | ||
DEFAULT_FIRESTORE_INSTANCE_PROVIDER, | ||
FIRESTORE_INSTANCES_PROVIDER, | ||
] | ||
}) | ||
export class FirestoreModule { | ||
} | ||
|
||
export function provideFirestore(fn: () => FirebaseFirestore): ModuleWithProviders<FirestoreModule> { | ||
return { | ||
ngModule: FirestoreModule, | ||
providers: [{ | ||
provide: PROVIDED_FIRESTORE_INSTANCES, | ||
useFactory: firestoreInstanceFactory(fn), | ||
multi: true, | ||
deps: [ | ||
NgZone, | ||
ɵAngularFireSchedulers, | ||
FirebaseApps, | ||
// Firestore+Auth work better if Auth is loaded first | ||
[new Optional(), AuthInstances ], | ||
] | ||
}] | ||
}; | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { FirebaseFirestore } from 'firebase/firestore/lite'; | ||
import { ɵgetAllInstancesOf } from '@angular/fire'; | ||
import { from, timer } from 'rxjs'; | ||
import { concatMap, distinct } from 'rxjs/operators'; | ||
|
||
// see notes in core/firebase.app.module.ts for why we're building the class like this | ||
// tslint:disable-next-line:no-empty-interface | ||
export interface Firestore extends FirebaseFirestore {} | ||
|
||
export class Firestore { | ||
constructor(firestore: FirebaseFirestore) { | ||
return firestore; | ||
} | ||
} | ||
|
||
export const FIRESTORE_PROVIDER_NAME = 'firestore/lite'; | ||
|
||
// tslint:disable-next-line:no-empty-interface | ||
export interface FirestoreInstances extends Array<FirebaseFirestore> {} | ||
|
||
export class FirestoreInstances { | ||
constructor() { | ||
return ɵgetAllInstancesOf<FirebaseFirestore>(FIRESTORE_PROVIDER_NAME); | ||
} | ||
} | ||
|
||
export const firestoreInstance$ = timer(0, 300).pipe( | ||
concatMap(() => from(ɵgetAllInstancesOf<FirebaseFirestore>(FIRESTORE_PROVIDER_NAME))), | ||
distinct(), | ||
); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"$schema": "../../../node_modules/ng-packagr/package.schema.json", | ||
"ngPackage": { | ||
"lib": { | ||
"umdModuleIds": { | ||
"rxfire/firestore-lite": "rxfire-firestore-lite" | ||
}, | ||
"entryFile": "public_api.ts" | ||
} | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export { Firestore, FirestoreInstances, firestoreInstance$ } from './lite'; | ||
export { FirestoreModule, provideFirestore } from './lite.module'; | ||
export * from './rxfire'; |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11678,10 +11678,10 @@ [email protected]: | |
resolved "https://registry.yarnpkg.com/rx/-/rx-2.3.24.tgz#14f950a4217d7e35daa71bbcbe58eff68ea4b2b7" | ||
integrity sha1-FPlQpCF9fjXapxu8vljv9o6ksrc= | ||
|
||
[email protected].cee1afe: | ||
version "6.0.0-canary.cee1afe" | ||
resolved "https://registry.yarnpkg.com/rxfire/-/rxfire-6.0.0-canary.cee1afe.tgz#212318f2ccc034c25581f079c51f0d952164b4db" | ||
integrity sha512-PySJryeUfnuMuYlC8U+X83PIe53G1s+OpQuzjjaMUQ3gc1z6aD4ZEWc/O3LzVQ3ywwO/X4AAO9hv4F0Q3+y79A== | ||
[email protected].92c6c26: | ||
version "6.0.0-canary.92c6c26" | ||
resolved "https://registry.yarnpkg.com/rxfire/-/rxfire-6.0.0-canary.92c6c26.tgz#de888ac0ec975eb7860b4cee54aa15df90b9fec0" | ||
integrity sha512-zqZZFTCFXqGNRIN/zciPVzylSw3drlkM3mojTZj4GALeUBtMI59/hmAEevbAxBQjNk4eiWj/4vFsPFJtzgT5qA== | ||
dependencies: | ||
tslib "^1.9.0 || ~2.1.0" | ||
|
||
|