DriftWorkerMode enum
Describes the topology between clients (e.g. tabs) and the drift web worker when spawned with connectToDriftWorker.
For more details on the individial modes, see the documentation on dedicated, shared and dedicatedInShared.
Values
- dedicated → const DriftWorkerMode
-
Starts a new, regular web
Worker
when connectToDriftWorker is called.This worker, which we expect is a Dart program calling driftWorkerMain in its
main
function compiled to JavaScript, will open a database connection internally. The connection returned by connectToDriftWorker will use a message channel between the initiating tab and this worker to run its operations on the worker, which can take load of the UI tab. However, it is not possible for a worker to be used across different tabs. To do that, shared or dedicatedInShared needs to be used. -
Starts a
SharedWorker
that is used across several browsing contexts (e.g. tabs or even a custom worker you wrote).This shared worker, which we expect is a Dart program calling driftWorkerMain in its
main
function compiled to JavaScript, will open a database connection internally. Just like for dedicated connections, the connection returned by connectToDriftWorker will use a message channel between the current context and the (potentially existing) shared worker.So, while every tab uses its own connection, they all connect to the same shared worker. Thus, every tab has a view of the same logical database. Even stream queries are synchronized across all tabs.
Note that shared worker may not be supported in all browsers.
-
This mode generally works very similar to shared in the sense that a shared worker is used and that all tabs calling driftWorkerMain get a view of the same database with synchronized stream queries.
However, a technical difference is that the actual database is not opened in the shared worker itself. Instead, the shared worker creates a new
Worker
internally that will host the database and forwards incoming connections to this worker. Generally, it is recommended to use a shared worker. However, some database connections, such as the one based on the Origin-private File System web API, is only available in dedicated workers. This setup enables the use of such APIs.Note that only Firefox seems to support spawning dedicated workers in shared workers, which makes this option effectively unsupported on Chrome and Safari.
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- index → int
-
A numeric identifier for the enumerated value.
no setterinherited
- name → String
-
Available on Enum, provided by the EnumName extension
The name of the enum value.no setter - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Constants
-
values
→ const List<
DriftWorkerMode> - A constant List of the values in this enum, in order of their declaration.