Closed danieljvdm closed 8 years ago
I figured out I can use a variable and the value
member!
After more thought, I feel like there has to be a better way to merge the signals into one array. Do you know of any? The way I'm currently using these extensions seems like it's not really doing more than the vanilla Firebase methods are, as I have to wrap most of the results in a Variable
to get a live array.
Hi @danieljvdm. I'm sorry I don't seem to understand what you're doing.
Are you trying to go from let usernames = ["max", "dan", "john"]
then map those to Observable<[UserModel]>
?
You can use combineLatest on an [Observable
So when dealing with the Event Types of .ChildAdded (or .ChildAnything), the callback is fired for every child and in the case of this Rx extension, we get n different observables for our n children. What should I do if I want each of those children to comprise an observable array? I.e., first signal comes in and gets mapped into an observable of an array, second comes in and we combine with our first one, etc..
What is your end Observable type? Is it a concatenated Observable<[UserModel]>
or
Observable<[[UserModel]]>
Observable<[UserModel]>
@danieljvdm Oh wow I swear I responded correctly to this.
your can do this:
let arrayOfObservables : [Observable<User>] = ["max", "john", "adam"].map{ username in
return rx_observeUserModel(username)
}
Then do this:
let combined : Observable<[UserModel]> = Observable.combineLatest(arrayOfObservables,
{ (values: [UserModel] in return values })
So if any of those Observables in the arrayOfObservables changes, you'll get the combined ones.
Does this help?
Yeah I figured this out awhile ago haha, I should have marked this issue closed. Thanks though!
It seem like Firebase returns a block for each child at a ref. I have an app with a table view and I want to pull it's data from a
Observable<[User]>
, but I get back a bunch ofObservable<User>
s from Firebase. How would you recommend going about this?