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

Adding more supported types #13

Closed
jbhoosreddy opened this issue Sep 9, 2016 · 8 comments
Closed

Adding more supported types #13

jbhoosreddy opened this issue Sep 9, 2016 · 8 comments

Comments

@jbhoosreddy
Copy link

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 and JSON.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.

@nolanlawson
Copy link
Owner

nolanlawson commented Sep 9, 2016

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! 😃

@nolanlawson
Copy link
Owner

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.

@jbhoosreddy
Copy link
Author

It's alright.. thanks for the tip though.

@viskin
Copy link

viskin commented Sep 22, 2016

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.

@nolanlawson
Copy link
Owner

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.

On Sep 22, 2016, at 7:22 AM, viskin notifications@github.com wrote:

Ok, I needed to move imageData blobs to and from web workers. So I forked the promise-worker library to promise-worker-transferable https://github.com/terikon/promise-worker-transferable.

Usage exactly as it's papa lib, with following possibility:

promiseWorker.postMessage(pingImageData, [pingImageData]) // 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]); // pongImageData transferred from worker to main
});
@jbhoosreddy https://github.com/jbhoosreddy, please use it if it helpful for you.


You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub #13 (comment), or mute the thread https://github.com/notifications/unsubscribe-auth/AARUwr_-5fMKTLqp6PhO-_WKynU9lOCDks5qso8PgaJpZM4J5PbI.

@viskin
Copy link

viskin commented Oct 26, 2016

Thanks!
Of course, everybody is invited to use and improve 👍

@jwmann
Copy link

jwmann commented Jan 12, 2018

@viskin I'm using your promise-worker-transferrable library to pass blobs back to my app.
This works great on every browser except for IE, even IE11.

I'm getting a Unhandled promise rejection DataCloneError
I'm not sure if it's because I'm transferring a blob in IE or if the promise web worker needs a shim or something.

I don't don't get this error with the regular promise-worker library

@jwmann
Copy link

jwmann commented Jan 15, 2018

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 webworker-promise with babel-polyfill

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

No branches or pull requests

4 participants