-
Notifications
You must be signed in to change notification settings - Fork 39
Consider async wrappers for Push/Pull methods #22
Copy link
Copy link
Open
Description
Hi, using your library (awesome btw!) I wrote little wrappers that take the REST functions and turn them to async methods.
I was thinking if you'd be interested in having something similar (more generic and with proper exception propagation, ofc) in the library itself. I was thinking about having one async method per operation e.g.:
class Firebase{
public Task<(Firebase, DataSnapshot)> PushStateAsync(string str)
{
var fbNode = this.Copy(); // (so that we can guarantee there's no callback sharing)
var taskCompletionSource = new TaskCompletionSource<(Firebase, DataSnapshot)>();
fbNode.OnPushSuccess += (Firebase node, DataSnapshot pushedKeyInfo) => { taskCompletionSource.SetResult((node, pushedKeyInfo)); }; ;
fbNode.OnPushFailed += (Firebase fireBase, FirebaseError error) => { taskCompletionSource.SetException(error); };
fbNode.Push(str);
return taskCompletionSource.Task;
}
}
I know it's not the most efficient implementation (a lot of allocations and whatnot) but it's not all that bad either.
I'd be happy to implement it but don't want to work on it in case it wouldn't be merged.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels