Closed masodev closed 5 years ago
Yes, the same, I thought, it is a feature of behaviour, when you are not authentificated, but EventSource value is OnlineStream as if event fires online. Looks like expensive bug.
Since you didn't specify any filtering option the AsObservable method will subscribe to the entire collection at specified node and you will initially receive everything online with subsequent changes coming in as they occur. AFAIK there is no way to skip this, since updates come in on individual fields (e. g. if you change date, the server only sends date, not the whole post). If you didn't have the initial state, you would be missing the rest of the object
Hey there Tomas, I only receive one item and not the entire collection.
On Mon, Feb 25, 2019, 21:01 Tomas Bezouska notifications@github.com wrote:
Since you didn't specify any filtering option the AsObservable method will subscribe to the entire collection at specified node and you will initially receive everything online with subsequent changes coming in as they occur. AFAIK there is no way to skip this, since updates come in on individual fields (e. g. if you change date, the server only sends date, not the whole post). If you didn't have the initial state, you would be missing the rest of the object
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/step-up-labs/firebase-database-dotnet/issues/189#issuecomment-467137105, or mute the thread https://github.com/notifications/unsubscribe-auth/AChXLIFxqmPSpv1E_I0qc6lN6cAKE3uMks5vRDMIgaJpZM4bFFW5 .
I have several subscriptions working in an app I'm working on. An example of one is shown below. One thing I noticed that's different with yours is in the .AsObservable() line, there's no object class designated (see my example below - "Event" is an object Class). I'm not an expert here - just know what I've done to get this to work. Also, in my example "returnedEvents" is an IDisposable. _returnedEvents is an ObservableCollection.
returnedEvents = App.firebase
.Child("Events")
.AsObservable<Event>()
.Subscribe(eventReceived =>
{
// check to see what type of FirebaseEvent was detected by the subscription
if (eventReceived.EventType == Firebase.Database.Streaming.FirebaseEventType.Delete)
// record deleted - remove from ObservableCollection
_returnedEvents.Remove(eventReceived.Object);
// record was added or updated
if (eventReceived.EventType == Firebase.Database.Streaming.FirebaseEventType.InsertOrUpdate)
{
// see if the inserted/updated object is already in our ObservableCollection
var found = _returnedEvents.FirstOrDefault(i => i.Key == eventReceived.Key);
if (found == null)
{
// is NOT in the observableCollection - add it
_returnedEvents.Add(eventReceived.Object);
}
// nothing to do if eventReceived is already in our ObservableCollection - because
// of INotifyPropertyChanged, the update will happen automatically
}
});
@TennisDrum Thanks that is helpful - maybe that's what I was missing! Will test and confirm as soon as possible.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Closing the issue due to inactivity. Feel free to re-open
Expecting key of updated post but instead receive the first post as listed on Realtime Database. Anyone else having this behaviour?