Skip to content

The Great Web Worker Refactor of 2014 #1434

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

Closed
wants to merge 1 commit into from

Conversation

petehunt
Copy link
Contributor

Using this branch to sync internally with FB, still needs polish and to be split up into multiple diffs.

globalObj = global;
}

invariant(globalObj, 'ExecutionEnvironment: could not find global object');
Copy link
Contributor

Choose a reason for hiding this comment

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

globalObj = this; maybe?

Copy link
Member

Choose a reason for hiding this comment

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

globalObj = this would be wrong, that's the scope of this module. We used to have globalObj = Function('return this;')() because that executes in a new global scope. But then we didn't need it and we removed it to be CSP safe. Not sure about self or global either... does one of those work in node?

Copy link
Contributor

Choose a reason for hiding this comment

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

I use globalObj = (function () { return this })() as cross-platform variant, returns global object in Node.js modules and window object in the browser.

Copy link
Contributor

Choose a reason for hiding this comment

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

If I recall correctly, (function() { return this })() won't return the global object in strict mode, which is part of the reason we were using Function("return this")() before.

Copy link
Contributor

Choose a reason for hiding this comment

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

You're right. In that case, since bundled file is usually already wrapped into kind of wrapper function (UMD or other; you're not setting strict mode globally anyway, right?), you can set this function to strict mode and pass global object from outside for any internal use:

(function (global) {
    'use strict';
    // ... all the real code goes here ...
})((function () { return this })());

or

(function (factory) {
    // your UMD or other wrapper
    factory(this);
}(function (global) {
    'use strict';
    // ... all the real code goes here ...
});

@petehunt petehunt changed the title The Great Web Worker Refactor of April 2014 The Great Web Worker Refactor of 2014 May 8, 2014
@facebook-github-bot
Copy link

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks!

@syranide
Copy link
Contributor

It seems like this PR is potentially a blocker for #1550 (until merged) as both incur quite substantial changes.

EDIT: Yeah, all of ReactMount packed up and moved elsewhere, so yeah, my #1570 definitely should wait.

working

make it more message passing-y

make triggerEvent public

fix reacttestutils

Tests passing

fix where files live, remove old toplevel callback

fix cloneWithProps tst

Use opaque DOM node handles

move mountimage stuff to use handles

fix almost all of the tests

all tests fixed

add the plan

fix bad rebase

mostly fix tests...mostly

completly unfuck rebase

make example look better

okay, apparently the test app works

fuck the tests

add reactworkermount

break events

revert other changes

revert reactjs changes

maybe fix things

fix server rendering

okay now all tests pass

begin cutting over to workermount

combine resolveDOMNodeHandle() and ReactDOMNodeMapping

move more stuff to dom node handles

sample apps work whatttttt

change container handles to use opaque ids

rename markup to image

fix todo

add helpful comment

update

make tests run again

Begin work on ReactRemote

bridge worker to dom

remove another reference to innerHTML

Add bootstrapping abilitiy

Rename ReactRemoteModule to RemoteModule

Bring ReactWorkerMount into the React global

reactworker is running

start adding injections

set up bidirectional comms

ReactWorkerReconcileTransaction

move some things around

move back containersByReactRootID

begin to break more dependencies

It finally works

serialize events over the bridge

remove some references to window in the event system

ok it works entirely now

make a new example for web workers

Clean up ReactWorker API

ReactWithWorkers entrypoint

reset React.js

Kill ReactInjection

Remove todo

remove some more todos

fix unmounting

reset basic example

@vjeux comments, fix typehints

fix typehints in ReactEventListener
@zpao
Copy link
Member

zpao commented Jun 23, 2014

Going to close this out since it's being split up and applied more piecemeal.

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.

7 participants