-
-
Notifications
You must be signed in to change notification settings - Fork 175
Open
Description
Hi, I want to discard all requests that are made as soon as I leave given scene, so my code is:
public class LadderRepository : MonoBehaviour {
private string uri = "my uri";
private readonly IList<RequestHelper> requests = new List<RequestHelper>();
public IPromise<LadderResponse> FetchLadder() {
var requestHelper = ComposeRequest(ladder);
return RestClient.Get<LadderResponse>(requestHelper);
}
private RequestHelper ComposeRequest(string url) {
var requestHelper = new RequestHelper {
Uri = url,
Timeout = 10
};
requests.Add(requestHelper);
return requestHelper;
}
private void OnDestroy() {
foreach (var requestHelper in requests) {
requestHelper.Abort();
}
requests.Clear();
}
}
I get exception in editor when calling requestHelper.Abort() :
ArgumentNullException: Value cannot be null.
Parameter name: _unity_self
Proyecto26.RequestHelper.Abort () (at Assets/RestClient/Packages/Proyecto26.RestClient/Helpers/RequestHelperExtension.cs:129)
Script.LadderRepository.OnDestroy () (at Assets/Script/Ladder/LadderRepository.cs:30)
I have unity 2019.2.13f1 and RestClient version 2.6.0. My idea is I dont want to receive any callbacks from any requests after user leaves given scene, cant tell what this error means though.