Skip to main content
Module

x/scaffold/src/deps/comlink.ts>TransferHandler

scaffold your next project with style and 💗
Latest
interface TransferHandler
import { type TransferHandler } from "https://deno.land/x/scaffold@0.3.0/src/deps/comlink.ts";

Customizes the serialization of certain values as determined by canHandle().

Type Parameters

T

The input type being handled by this transfer handler.

S

The serialized type sent over the wire.

Methods

canHandle(value: unknown): value is T

Gets called for every value to determine whether this transfer handler should serialize the value, which includes checking that it is of the right type (but can perform checks beyond that as well).

serialize(value: T): [S, Transferable[]]

Gets called with the value if canHandle() returned true to produce a value that can be sent in a message, consisting of structured-cloneable values and/or transferrable objects.

deserialize(value: S): T

Gets called to deserialize an incoming value that was serialized in the other thread with this transfer handler (known through the name it was registered under).