T.Akashi
T.Akashi

Reputation: 1221

Firebase. Is there way to ignore calling childAdded on iOS?

I'm listing data with childAdded observer in iOS. I understand this is Firebase design and it is called at first time to list data and when data is added.

I dont't want to call childAdded when data is added. I'm having idea FEventTypeValue can not be call when list data.(is it correct?)

My question:

Is there way to ignore childAdded only when data is added or to list data at first time without childAdded?

Sorry for my English. Thanks for Advance!

Upvotes: 0

Views: 450

Answers (1)

Kato
Kato

Reputation: 40582

The iOS/OS X Quick Start uses this example. Essentially, you're just grabbing the entire value of the path rather than watching it for child events:

// Read data and react to changes
[f observeEventType:FEventTypeValue withBlock:^(FDataSnapshot *snapshot) {
  NSLog(@"%@ -> %@", snapshot.name, snapshot.value);
}];

To receive the value only once, instead of each time there is a change, you can utilize the observeSingleEventOfType method:

// Read data and react to changes
[f observeSingleEventOfType:FEventTypeValue withBlock:^(FDataSnapshot *snapshot) {
  NSLog(@"%@ -> %@", snapshot.name, snapshot.value);
}];

Upvotes: 2

Related Questions