查询后FirebaseListObservable变为可观察 [英] FirebaseListObservable becomes Observable after query
问题描述
以下内容返回FirebaseListObservable。
this.resources $ = < FirebaseListObservable<的IResource [] GT;> this.af.list(`/ resources / $ {this.auth.id}`)作为FirebaseListObservable< IResource []>;
//这将返回一个常规的可观察值。
this.resources $ =< FirebaseListObservable< IResource []>> this.af.list(`/ resources / $ {this.auth.id}`,
{
query:{
orderByChild:`$ {property}`
}
}
)as FirebaseListObservable< IResource []>;
但是这会返回一个普通的旧观察值。问题是我需要一个FirebaseListObservable,因为它已经添加了CRUD功能,我正在尝试编写简单的过滤/排序方法。
我可以看到他们有一个 Open Issue ,但是我希望能早日解决这个问题, 。在故障单中讨论的解决方案描述了扩展FirebaseListObservable并重写lift方法以返回自定义observable。我试图创建一个CustomFirebaseListObservable这样做,但我似乎没有访问正确的属性(observable.source和observable.operator从我的自定义observable。我希望有一种方法来将一个可观察的如果你仍然有这个问题,也许你可以创建一个firebase的参考,你可以创建一个firebaseListObservable。任何解决方法将真正做到。
订单,然后将它传递到angularfire?
$ $ $ $ $ $ $ $让refPath =`/ resources / $ {this.auth.id}`, $ ref $ firebase.database ref(refPath).orderByChild(property);
this.resources $ =< FirebaseListObservable< IResource []>> this.af.list(ref) ;
I made a small app on firebase. I have been using a type provided by angularfire called a FirebaseListObservable which allows you to observe changes to your data. The problem I'm having is that Angularfire also provides a way to query the data, by attaching / passing in a query object to the request.
The following returns a FirebaseListObservable.
this.resources$ = <FirebaseListObservable<IResource[]>> this.af.list(`/resources/${this.auth.id}`) as FirebaseListObservable<IResource[]>;
//This returns a regular observable.
this.resources$ = <FirebaseListObservable<IResource[]>> this.af.list(`/resources/${this.auth.id}`,
{
query: {
orderByChild: `${property}`
}
}
) as FirebaseListObservable<IResource[]>;
But this returns a plain old observable. The issue is that I need a FirebaseListObservable because it has added CRUD functionality and I'm trying to write simple filter / sorting methods.
I can see they have an Open Issue for this but I'm hoping that there is a way around this issue sooner rather than later. The solution discussed in the ticket describes extending the FirebaseListObservable and overriding the lift method to return the custom observable. I attempted to create a CustomFirebaseListObservable that does just that, but I don't seem to have access to the correct properties (observable.source and observable.operator from within my custom observable. I'm hoping for a way to cast an observable to a firebaseListObservable. Any workaround would do really.
If you are still having this issue, maybe you can create the firebase reference with the ordering and then passing that into angularfire?
let refPath = `/resources/${this.auth.id}`,
ref = firebase.database().ref(refPath).orderByChild(property);
this.resources$ = <FirebaseListObservable<IResource[]>>this.af.list(ref);
这篇关于查询后FirebaseListObservable变为可观察的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!