setCancelCallback method
- ResourceRequestCancelHandler handler
Calls a callback when the library cancels a resource request.
The callback never runs after the request is answered. A request takes one cancel callback. When the library has already cancelled the request, the call reports that instead and the callback never runs.
See mln_resource_request_set_cancel_callback in the
C API reference.
Implementation
bool setCancelCallback(ResourceRequestCancelHandler handler) =>
withNativeArena((arena) {
final outCancelled = arena<Bool>();
final registrations = _NativeRegistrations(_callbackRoots);
_check(
registrations.run(
() => raw.mln_resource_request_set_cancel_callback(
_handle.raw,
registrations.add(
_prepareResourceRequestCancelHandler(
handler,
registrations.roots,
),
),
outCancelled,
nativeDiagnostic,
),
declined: () => outCancelled.value,
),
);
return outCancelled.value;
});