There is a reason why not to use "BridgeConnector.Socket.Once"? #919
-
|
I've noticed throughout the codebaese a lot of instances like this one: public Task<Point> GetCursorScreenPointAsync()
{
var taskCompletionSource = new TaskCompletionSource<Point>();
BridgeConnector.Socket.On<Point>("screen-getCursorScreenPointCompleted", (point) =>
{
BridgeConnector.Socket.Off("screen-getCursorScreenPointCompleted");
taskCompletionSource.SetResult(point);
});
BridgeConnector.Socket.Emit("screen-getCursorScreenPoint");
return taskCompletionSource.Task;
}Why this can't be translated into: public Task<Point> GetCursorScreenPointAsync()
{
var taskCompletionSource = new TaskCompletionSource<Point>();
BridgeConnector.Socket.Once<Point>("screen-getCursorScreenPointCompleted", taskCompletionSource.SetResult);
BridgeConnector.Socket.Emit("screen-getCursorScreenPoint");
return taskCompletionSource.Task;
}There is a specific reason not to do so? |
Beta Was this translation helpful? Give feedback.
Answered by
FlorianRappl
Nov 10, 2025
Replies: 1 comment 2 replies
-
|
My guess is that Otherwise you are right - |
Beta Was this translation helpful? Give feedback.
2 replies
Answer selected by
Denny09310
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
My guess is that
Oncemay not have been available historically.Otherwise you are right -
Onceshould be used.