DataSourceRequest#
Added in version 1.1.
Superclasses: Object
Represents a request to a DataSource for a tile.
Data sources can return a tile multiple times. For example, a
TileDownloader may return cached data first, then later return data
from a network service when it arrives. This allows the map to be rendered
as quickly as possible without waiting for the network unnecessarily.
Conventional async/finish method pairs don’t support multiple returns.
Instead, start_request is available, which returns a
DataSourceRequest whose properties, data
and error, update as data becomes available.
The notify signal can be used to watch for these
changes. When the request is done and no more data will be returned,
completed is set to True.
DataSource implementations can use a subclass of
DataSourceRequest, but the base class should be sufficient in most
cases.
Constructors#
- class DataSourceRequest
- classmethod new(x: int, y: int, zoom_level: int) DataSourceRequest#
Creates a new
DataSourceRequest.Only implementations of
start_requestshould need to construct a new request object.Added in version 1.1.
- Parameters:
x – X coordinate of the requested tile
y – Y coordinate of the requested tile
zoom_level – Zoom level of the requested tile
Methods#
- class DataSourceRequest
- complete() None#
Marks the request as complete. No more data or errors may be emitted.
This can only be called if data has been emitted. If there is no data, use
emit_errorinstead, which will automatically complete the request.Added in version 1.1.
- emit_data(data: Bytes, complete: bool) None#
Emits tile data as a response to the request. This sets the
dataproperty.If
completeisTrue, thencompletedis set toTrueas well.Added in version 1.1.
- Parameters:
data – the data to emit
complete –
Trueto also complete the request,Falseotherwise
- emit_error(error: GError) None#
Emits a fatal error in response to the request. This completes the request, so no more data or errors can be emitted after this. Non-fatal errors should not be reported.
If
datawas previously set, it will be cleared.Added in version 1.1.
- Parameters:
error – an error
Properties#
- class DataSourceRequest
-
- props.error: GError#
The type of the None singleton.
Added in version 1.1.
Fields#
- class DataSourceRequest
- parent_instance#