Table of Contents

Class BackgroundFetchRegistration

Namespace
CSharpToJavaScript.APIs.JS
Assembly
CSharpToJavaScript.dll
NOTE
Experimental
The BackgroundFetchRegistration interface of the 'Background Fetch API' represents an individual background fetch.
[Value("BackgroundFetchRegistration")]
public class BackgroundFetchRegistration : EventTarget
Inheritance
BackgroundFetchRegistration
Inherited Members

Remarks

A BackgroundFetchRegistration instance is returned by the Fetch(string, Union0, BackgroundFetchOptions) or Get(string) methods, and therefore there has no constructor.

See also on MDN

Constructors

BackgroundFetchRegistration()

public BackgroundFetchRegistration()

Properties

DownloadTotal

NOTE
Experimental
The downloadTotal read-only property of the BackgroundFetchRegistration interface returns the total size in bytes of this download. This is set when the background fetch was registered, or 0 if not set.
[Value("downloadTotal")]
public ulong DownloadTotal { get; }

Property Value

ulong

A Number.

Remarks

Downloaded

NOTE
Experimental
The downloaded read-only property of the BackgroundFetchRegistration interface returns the size in bytes that has been downloaded, initially 0.
[Value("downloaded")]
public ulong Downloaded { get; }

Property Value

ulong

A Number.

Remarks

If the value of this property changes, the progress event is fired at the associated BackgroundFetchRegistration object.

See also on MDN

FailureReason

NOTE
Experimental
The failureReason read-only property of the BackgroundFetchRegistration interface returns a string with a value that indicates a reason for a background fetch failure.
[Value("failureReason")]
public BackgroundFetchFailureReason FailureReason { get; }

Property Value

BackgroundFetchFailureReason

One of the following strings:

Remarks

If the value of this property changes, the progress event is fired at the associated BackgroundFetchRegistration object.

See also on MDN

Id

NOTE
Experimental
The id read-only property of the BackgroundFetchRegistration interface returns a copy of the background fetch's ID.
[Value("id")]
public string Id { get; }

Property Value

string

A string.

Remarks

Onprogress

[Value("onprogress")]
public EventHandlerNonNull Onprogress { get; set; }

Property Value

EventHandlerNonNull

RecordsAvailable

NOTE
Experimental
The recordsAvailable read-only property of the BackgroundFetchRegistration interface returns true if there are requests and responses to be accessed. If this returns false, then Match(Union42, CacheQueryOptions) and MatchAll(Union42, CacheQueryOptions) can't be used.
[Value("recordsAvailable")]
public bool RecordsAvailable { get; }

Property Value

bool

A Boolean.

Remarks

Result

NOTE
Experimental
The result read-only property of the BackgroundFetchRegistration interface returns a string indicating whether the background fetch was successful or failed.
[Value("result")]
public BackgroundFetchResult Result { get; }

Property Value

BackgroundFetchResult

One of the following strings:

Remarks

If the value of this property changes, the progress event is fired at the associated BackgroundFetchRegistration object.

See also on MDN

UploadTotal

NOTE
Experimental
The uploadTotal read-only property of the BackgroundFetchRegistration interface returns the total number of bytes to be sent to the server.
[Value("uploadTotal")]
public ulong UploadTotal { get; }

Property Value

ulong

A Number.

Remarks

Uploaded

NOTE
Experimental
The uploaded read-only property of the BackgroundFetchRegistration interface returns the size in bytes successfully sent, initially 0.
[Value("uploaded")]
public ulong Uploaded { get; }

Property Value

ulong

A Number.

Remarks

If the value of this property changes, the progress event is fired at the associated BackgroundFetchRegistration object.

See also on MDN

Methods

Abort()

NOTE
Experimental
The abort() method of the BackgroundFetchRegistration interface aborts an active background fetch.
[Value("abort")]
public Task<bool> Abort()

Returns

Task<bool>

A Promise that resolves with true if the fetch is successfully aborted.

Remarks

Match(Union42, CacheQueryOptions)

NOTE
Experimental
The match() method of the BackgroundFetchRegistration interface returns the first matching BackgroundFetchRecord.
[Value("match")]
public Task<BackgroundFetchRecord> Match(Union42 request, CacheQueryOptions options = null)

Parameters

request Union42
options CacheQueryOptions

Returns

Task<BackgroundFetchRecord>

A {{jsxref("Promise")}} that resolves with the first BackgroundFetchRecord that matches
the request or GlobalObject.Undefined if no match is found.

NOTE
BackgroundFetchRegistration.match() is basically identical to
MatchAll(Union42, CacheQueryOptions), except that rather than resolving with an array of
all matching records, it resolves with the first matching record only.

Remarks

MatchAll(Union42, CacheQueryOptions)

NOTE
Experimental
The matchAll() method of the BackgroundFetchRegistration interface returns an array of matching BackgroundFetchRecord objects.
[Value("matchAll")]
public Task<List<BackgroundFetchRecord>> MatchAll(Union42 request = default, CacheQueryOptions options = null)

Parameters

request Union42
options CacheQueryOptions

Returns

Task<List<BackgroundFetchRecord>>

A {{jsxref("Promise")}} that resolves with an array of all matching BackgroundFetchRecord objects.

Remarks