-
Notifications
You must be signed in to change notification settings - Fork 40
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
Adding more supported types #13
Comments
It's actually more efficient to directly pass Blobs as transferables rather than stringifying them. However, I've decided I'm not interested in adding a lot of bells and whistles to promise-worker. I like keeping it simple instead. If you need support for base64/blobs/etc. then I encourage you to fork it to write your own; the code is very accessible! 😃 |
Also sorry if this sounds like shutting you down; I think it's a great idea and I encourage you to do it; it's just really hard to maintain larger OSS projects, so I am (selfishly) making my own life easier by keeping the scope of this project small. |
It's alright.. thanks for the tip though. |
Ok, I needed to move imageData blobs to and from web workers. So I forked the promise-worker library to promise-worker-transferable. Usage exactly as it's papa lib, with following possibility: promiseWorker.postMessage(pingImageData, [pingImageData.data.buffer]) // pongImageData transferred from main to worker
.then(function (response) {
// handle response
}).catch(function (error) {
// handle error
}); and vice versa: registerPromiseWorker(function (message, withTransferList) {
return withTransferList(pongImageData, [pongImageData.data.buffer]); // pongImageData transferred from worker to main
}); @jbhoosreddy, please use it if it helpful for you. |
That’s a great solution. :) I’m happy to add a PR to the README to recommend folks look at promise-worker-transferable if that’s okay with you.
|
Thanks! |
@viskin I'm using your promise-worker-transferrable library to pass blobs back to my app. I'm getting a I don't don't get this error with the regular promise-worker library |
This likely due to the fact that IE doesn't support transferable objects but it technically can support Blobs without that feature. I ended up using |
I read the discussion in #1 and I fully agree keeping a simple api for developers.
For my purposes, I converted
Blob
to a Data URI string and passed it back.But looking on the internet I found libraries which are similar to
JSON.stringify
andJSON.parse
but they now support "stringifying" a whole range of complex objects.I was wondering if we could discuss about it and maybe you could tell me the reasons why they would not be useful, if that is the case.
I could submit a PR if it is not such a bad idea and we could see how that works.
The text was updated successfully, but these errors were encountered: