Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for async serialize/deserialize of transferHandler #1

Merged
merged 6 commits into from
Apr 10, 2024

Conversation

taro-28
Copy link
Member

@taro-28 taro-28 commented Apr 9, 2024

Motivation

Enabled to use async functions for serialize and deserialize of transferHandlers to transfer such as Blob.

Example

import * as Comlink from "comlink";

Comlink.transferHandlers.set("blob", {
  canHandle: (obj): obj is Blob => obj instanceof Blob,
  // Enable to use async functions.
  serialize: async (blob: Blob) => [
    { data: await blob.arrayBuffer(), type: blob.type, size: blob.size },
    [],
  ],
  deserialize: async (obj: BlobObject): Promise<Blob> =>
    new Blob([obj.data], { type: obj.type }),
});

Related

GoogleChromeLabs#646

@taro-28 taro-28 self-assigned this Apr 9, 2024
@taro-28 taro-28 changed the title Async wire value Support for async transferHandle serializer/deserializer Apr 10, 2024
@taro-28 taro-28 changed the title Support for async transferHandle serializer/deserializer Support for async serialize/deserialize of transferHandler Apr 10, 2024
@taro-28 taro-28 marked this pull request as ready for review April 10, 2024 08:44
Copy link
Member

@syumai syumai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants