Serialize strategy for entities
thomasboyt opened this issue · comments
Concerns:
postMessage
can handle circular dependencies. It's unclear ifchrome.runtime.sendMessage
can do so as well. Hopefully, it can, since this will remove the need for a lib that handles circular refs, and will allow the object to be unpacked in a circular mannerpostMessage
cannot handle (per MDN) DOM nodes, functions, and errors
It seems like, before being sent through postMessage, an entity needs to be cleaned of unserializable parts. It seems like the only clean way to do this is to piggy-back off of an existing in-JS structured clone implementation.
Possible options:
- cycloneJS allows custom clone procedures so e.g. functions and DOM nodes can be replaced with string placeholders
Whoops, chrome's port.postMessage
is a TOTALLY DIFFERENT API from window.postMessage
, and internally uses JSON.stringfy
instead of a structured clone algorithm! Gross.
Will need to rethink.
current status: fuckit.js