Namespace: SpawnDev.SpawnJS.JSObjects
Source: JSObjects/SharedWorkerOptions.cs
MDN Reference: SharedWorkerOptions on MDN
An object containing option properties that can set when creating the SharedWorker instance. https://developer.mozilla.org/en-US/docs/Web/API/SharedWorker/SharedWorker#options
| Property | Type | Access | Description |
|---|---|---|---|
SharedWorkerOptions |
class |
get | An object containing option properties that can set when creating the SharedWorker instance. https://developer.mozilla.org/en-US/docs/Web/API/SharedWorker/SharedWorker#options |
Credentials |
string? |
get | |
Name |
string? |
get | |
SameSiteCookies |
string? |
get |
SpawnDev.SpawnJS Mapping Note: The JavaScript examples below show the standard Web API usage. In SpawnDev.SpawnJS, the same API is available with C# conventions:
- Properties and methods use PascalCase (e.g.,
readyStatebecomesReadyState)- Events use ActionEvent with
+=/-=(e.g.,addEventListener("click", fn)becomesOnClick += handler)- Async methods return
Task<T>instead ofPromise<T>- Objects should be disposed with
usingstatements- Access via
JS.Get<SharedWorkerOptions>(...)or constructornew SharedWorkerOptions(...)
const myWorker = new SharedWorker("worker.js");
myWorker.port.start();
[first, second].forEach((input) => {
input.onchange = () => {
myWorker.port.postMessage([first.value, second.value]);
console.log("Message posted to worker");
};
});
myWorker.port.onmessage = (e) => {
result1.textContent = e.data;
console.log("Message received from worker");
};