thomasantony / flybywire

A React-inspired declarative library for building DOM-based user interfaces in pure Python.
MIT License
112 stars 6 forks source link

Decrease domevent Message Size #1

Open grantjenks opened 8 years ago

grantjenks commented 8 years ago

Awesome library. I have wanted to make something like this. Thank you.

I noticed you're using virtual-dom to do dom manipulation client-side and vdom-as-json to communicate with the Python server. I browsed vdom-as-json and it suggested using vdom-serialized-patch to reduce the serialized patch message size. I think you're currently sending the whole dom tree on every domevent message. Is that right?

I inspected vdom-serialized-patch and I couldn't tell whether it was reusing the patch function provided by virtual-dom or if it had implemented it's own. Ideally I think the client-side library would simply know how to apply patches and the server-side Python could create these patch objects serialized as JSON.

Any thoughts about how to reduce the message size?

thomasantony commented 8 years ago

Yes. I am sending the whole virtual DOM tree with each render command. I know it's not exactly the most efficient way to do this. I considered doing the diff-ing process in Python and sending just the patch over JSON. However, it would've taken too long for me to decipher how exactly virtual-dom/diff works to implement it in Python.

If virtual-dom/diff can be implemented in Python, sending just the patch over JSON so that it is compatible with vdom-serialized-patch should be an easy enough task. That would definitely be more efficient. I would even be open to switching some other system entire which already does virtual DOM manipulation and diffing in Python.

You are welcome to work on this and send a PR. I will take a look. 😃

Right now I am focusing on some other features such the 'refs' and getDOMNode() functionality from React.