question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Lower-level patch API

See original GitHub issue

Hi,

As some may know I am experimenting with running Cycle in WebWorkers. It works pretty well, but the main bottleneck is the postMessage API. Right now I am transmitting something i call vDOMSON, representing the entire component vTree, this is then mapped recursively to snabbdom/h which in turn is passed to the patch function.

To reduce I/O I thought it could be neat to have patch in two parts, so instead of transmitting the entire vDOMSON, I can just transmit a list of mutations. The pre-patch could be run in the sub-thread, while the resulting mutations could be transferred to and applied in the main thread.

I know it sounds kind of insane.

Issue Analytics

  • State:open
  • Created 7 years ago
  • Comments:15 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
mightyiamcommented, Jan 8, 2020

@aronallen title change OK with you?

1reaction
staltzcommented, Jan 20, 2017

@aronallen check out snabbdom’s DOMAPI. It’s essentially a wrapper for anything that actually touches the real DOM. Perhaps you can send serializations that refer to calls of those methods.

interface DOMAPI {
  createElement: (tagName: any) => HTMLElement;
  createElementNS: (namespaceURI: string, qualifiedName: string) => Element;
  createTextNode: (text: string) => Text;
  insertBefore: (parentNode: Node, newNode: Node, referenceNode: Node | null) => void;
  removeChild: (node: Node, child: Node) => void;
  appendChild: (node: Node, child: Node) => void;
  parentNode: (node: Node) => Node;
  nextSibling: (node: Node) => Node;
  tagName: (elm: Element) => string;
  setTextContent: (node: Node, text: string | null) => void;
}

The cool thing about snabbdom is that you can pass an instance of domAPI to init().

I know some of these methods take Element as argument, but this is actually vnode.elm, so it could be that vnode.elm on the web worker side is just some kind of virtual pointer (a string, if nothing else) to an element on the DOM.

Just an idea…

Read more comments on GitHub >

github_iconTop Results From Across the Web

HTTP PUT vs HTTP PATCH in a REST API
In this quick tutorial, we're looking at differences between the HTTP PUT and PATCH verbs and at the semantics of the two operations....
Read more >
All you need to know about why and where to use Put vs Patch
We are very glad to start the REST APIs made easy course with the very first video on fundamentals of REST APIs, HTTP...
Read more >
PATCH method on exposed REST services
PATCH method allows a new HTTP method when exposing REST APIs that applies partial modifications to a resource.
Read more >
Serverless API Essentials: PUT vs PATCH
If a resource has elements to it that are under a level of access control or it is too large to feasibly ask...
Read more >
The case against the generic use of PATCH and PUT in REST ...
There is a lot of confusion among developers on how to implement updates using a REST API. The tools we are given (...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found