bugthesystem / FireSharp

An asynchronous cross-platform .Net library for Firebase
The Unlicense
696 stars 147 forks source link

Cancel OnAsync() #25

Closed ThomasCle closed 8 years ago

ThomasCle commented 8 years ago

I am using the "OnAsync" method. Is there a way to stop the listening for events? In my case the user can disable the tracking of changes and then I would like to cancel the OnAsync.

There is a cancel implemented internally, but it is not implemented to client.

Thanks.

bugthesystem commented 8 years ago

@ThomasCle Thanks for your feedback, you can stop listening for events by calling EventStreamResponse's Dispose method. Here is sample code;

 EventStreamResponse response = await _client.OnAsync("chat",
                added: (sender, args) => { System.Console.WriteLine(args.Data + " -> 2\n"); },
                changed: (sender, args) => { System.Console.WriteLine(args.Data); },
                removed: (sender, args) => { System.Console.WriteLine(args.Path); });

//Call dispose to stop listening for events
response.Dispose();

This is supported by 2.* versions.

krishnendra1987 commented 8 years ago

Hello ziya .can you please let me know how to continously get data from firebase database into xamrin.ios. I managed to get data by using firebaseclient.get() method but if any new data comes into database how can we get without refreshing .