angularfire icon indicating copy to clipboard operation
angularfire copied to clipboard

Has .taken been removed from FirebaseObjectObservable?

Open danielordonez opened this issue 10 years ago • 4 comments

I need to replicate the .once functionality from the sdk but the only support that I found here suggests that I use the .take() property and it appears to not be defined in FirebaseObjectObservable types, any suggestions?

this.af.database.object('someLocation').take(1).subscribe(...)

danielordonez avatar Sep 22 '16 05:09 danielordonez

@danielordonez Look at this issue You should have your answer.

you need to add this line in your imports at the top of your component. import 'rxjs/add/operator/take'

mukesh51 avatar Sep 22 '16 08:09 mukesh51

Thank you very much @mukesh51 , I was able to add the .take property.

Right now, however, my real issue is that I am trying to bind an object property to an input, which will get updated each time a user types or remains inactive for a few milliseconds.

I'm not sure how unreliable it may get if my application's input is sync'd in real time, meaning that the input's value could change if the value in the database is newer (a single user would be the only one typing on that input at the time, though), that's why I just wanted to retrieve the value once and let the user update the value of the input freely and then view the changes from the database when he reloads the webpage.

For some reason, If I do a traditional binding to my application and retrieve the object like it says in the tutorial:

https://github.com/angular/angularfire2/blob/master/docs/2-retrieving-data-as-objects.md

I get not issues at all, my object is retrieved as expected:

{"name": "value"}

But when I try to take the snapshot, I can't get the value returned in the same way, I just get this if I capture the returned value to the console and when I make the reference in my input it just says undefined:

FirebaseObjectObservable {_isScalar: false, _ref: U}

Sorry if it's a dumb question or it has been asked before, I'm a newbie and I'm just finding my way through AngularFire2.

Any ideas how I should handle this?

danielordonez avatar Sep 22 '16 14:09 danielordonez

Not sure, if I get your question correctly, but with the input field, where you're trying to sync the value from Firebase, why not try some time based operations like delay or debounce, so that you can delay your callback.

mukesh51 avatar Sep 22 '16 15:09 mukesh51

Seems like a good solution to my question, thank you @mukesh51 !

danielordonez avatar Sep 22 '16 16:09 danielordonez