Skip to content
This repository has been archived by the owner on Mar 25, 2019. It is now read-only.

Worker Example #2

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

Worker Example #2

wants to merge 4 commits into from

Conversation

Aintaer
Copy link

@Aintaer Aintaer commented Jul 20, 2012

I would also like to include the ability to H5.worker( H5.blob() ), but that can wait till BlobBuilder is ready.

@Aintaer
Copy link
Author

Aintaer commented Jul 20, 2012

  1. event.preventDefault(), as I understand it, is used when chaining Workers such that if a Worker is spawned from inside a Worker, the error from the child Worker can be canceled by the parent Worker so as not to reach the Worker global scope and erroring out the entire "stack" of Workers. It doesn't bubble in the classical sense since there's no DOM to bubble through.

  2. Worker's receive() to me is analogous to XHR's success(). While it's highly helpful to have a once(callback), it feels out of the scope of a facade. It's simple enough to attach more robust event handling to the facade; I also fear that once you add event handling with once() you will need the ability to on() and off().

    Basically, it comes down to whether or not you expect to be able to call receive() multiple times to attach multiple callback handlers. My feeling is if you're expecting that layer, you might as well use libraries that dedicate themselves to that (e.g. jQuery.Callbacks).

  3. Good point, I'll think that over but basically I would expect it to be like the H5.worker in the global scope, only without the error(). The send() and receive() methods would basically be matched with the receive() and send() of its parent.

    Something to keep in mind is that loading scripts inside the Worker must be done within cross-domain boundaries and with a much more restrictive set of APIs. So whatever H5.worker(self) provides inside the Worker is forced to be lean!

@Aintaer
Copy link
Author

Aintaer commented Jul 31, 2012

I've added the first implementation of h5.worker. However I don't know what I should do with the initialization options.

  1. Should I allow an object format specifying the callbacks as well?
  2. What happens if they call worker on something that's not possible to become a worker?

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

Successfully merging this pull request may close these issues.

2 participants