-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
valueChanges does not inherit type of list/object #1214
Comments
valueChanges does return an |
Yup, but I need to specify the generic twice: this.db.list<MyInterface>('/stuff')
.valueChanges<MyInterface>(); Whereas this is much more preferable: this.db.list<MyInterface>('/stuff')
.valueChanges(); // currently returns Observable<{}[]> |
Also this is "valid" code currently: let stuff = this.db.list<number>('/stuff'); // stuff is a list of numbers, sure
let stuff$ = stuff.valueChanges<string>(); // wait, it's a list of strings now?
stuff.push(1); // But I can push a number? |
No you don't see here, https://stackblitz.com/edit/angular-template-firebase-uxldsj?file=app%2Fapp.module.ts if you second example you're overriding the generic with another, which is fine. |
@Toxicable Your example is for Cloud Firestore, not Realtime Database. If I modify your example to use the Realtime Database, it fails. https://stackblitz.com/edit/angular-template-firebase-7mn3ay |
Also, Firestore does not have a generic specific for collection.valueChanges, but rather uses the one already on the collection. |
Version info
Angular: 4.4.4
Firebase: 4.5.0
AngularFire: 5.0.0-rc.0-next
The problem
AngularFireList
andAngularFireObject
has a genericT
that is not inherited to all of it's members, such asvalueChanges
orsnapshotChanges
.Is it possible to have a generic for
snapshotChanges
? It returns aSnapshotAction
, which in turn contains afirebase.database.DataSnapshot
, which is not generic.Links to related Interfaces
AngularFireList
AngularFireObject
The fix
(if I'm correct)
Should I open a PR?
The text was updated successfully, but these errors were encountered: