mirror of
https://github.com/ppy/osu.git
synced 2024-11-06 06:57:39 +08:00
Allow OverlayView fetching with no API requests required
This commit is contained in:
parent
78ce6f1cd2
commit
449b9a21ae
@ -42,25 +42,29 @@ namespace osu.Game.Overlays
|
||||
/// <summary>
|
||||
/// Create the API request for fetching data.
|
||||
/// </summary>
|
||||
protected abstract APIRequest<T> CreateRequest();
|
||||
protected virtual APIRequest<T> CreateRequest() => null;
|
||||
|
||||
/// <summary>
|
||||
/// Fired when results arrive from the main API request.
|
||||
/// </summary>
|
||||
/// <param name="response"></param>
|
||||
protected abstract void OnSuccess(T response);
|
||||
protected virtual void OnSuccess(T response)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Force a re-request for data from the API.
|
||||
/// </summary>
|
||||
protected void PerformFetch()
|
||||
protected virtual void PerformFetch()
|
||||
{
|
||||
request?.Cancel();
|
||||
|
||||
request = CreateRequest();
|
||||
request.Success += response => Schedule(() => OnSuccess(response));
|
||||
|
||||
API.Queue(request);
|
||||
if (request != null)
|
||||
{
|
||||
request.Success += response => Schedule(() => OnSuccess(response));
|
||||
API.Queue(request);
|
||||
}
|
||||
}
|
||||
|
||||
private void onlineStateChanged(ValueChangedEvent<APIState> state) => Schedule(() =>
|
||||
|
Loading…
Reference in New Issue
Block a user