Skip to content
This repository was archived by the owner on Sep 21, 2022. It is now read-only.
This repository was archived by the owner on Sep 21, 2022. It is now read-only.

Web Worker Rendering Idea #32

@RGBboy

Description

@RGBboy

After reading the Angular 2 google doc on rendering architecture
I got thinking about how this could be achieved with React. Wouldn't it be awesome if a web worker could be used for your application logic so the main thread can stay responsive to user interaction? Imagine if you could send a virtual dom diff from a worker to the main thread.

The current problem with this architecture is that a virtual element is not always serializable. This is because we want to be able to attach event handlers to respond to events triggered by a user. These event handlers are not always called with serializable arguments for example DOM elements. What if instead you could describe your event handler in terms of a function and that functions data dependencies? Perhaps something similar to GraphQL. Then just let the main thread send what is required when such an event is triggered. A virtual element could then be serialized and sent over a web worker message channel.

You could take this a step further and take advantage of the diffing process. Only send the diffs of the elements that have changed including the changes in data dependency. When a user triggers an event the Main thread figures out the event and the required data and sends it back to the UI thread.

You could potentially get multiple UI threads sending diffs to the main thread as long as each UI thread owned a given branch of the virtual tree.

Does this sound like something worth exploring? Am I missing something that would stop this from working?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions