3 ms·
This is nice. I’m curious — it looks like you’re storing the full text string along with the timestamp. At first I thought you were capturing keystrokes, but i
by sonofhans 3y ago
This is nice.
I’m curious — it looks like you’re storing the full text string along with the timestamp. At first I thought you were capturing keystrokes, but it makes more sense to capture the full text, so you can allow people to edit with mouse/arrow keys, etc.
It will fall over at some point though, right? If you work on this more, is the next logical step to store a diff with each timestamp, rather than the full string?
- seafoamteal 3y agoThat's what I was thinking as well. I loved the demo, but was a bit surprised at how much redundant data was stored behind the scenes. Capturing keystrokes could still be a viable option if you maintained something like a virtual cursor that could move around the text display area. Or of course, diffs are the most straightforward way to do it.
- Einenlum 3y agoThanks, this is an interesting point. Storing the full message indeed has a downside in terms of storage (but for a short text it should be unnoticeable). I guess it also brings something positive: you can select the whole text, delete it, and start again, and the whole action should be stored. Making a diff to represent this is way more complicated. I'll still think about this though. I think I could find a way to reduce the data size for most use cases.
- Einenlum 3y agoI changed the code to add a diff. Thanks for your input! (pun intended)
- sonofhans 3y agoThat was quick! It seems to work as well as ever. The data structure is less legible, but a lot more efficient. Such a little project. I hope to find a use for it.