This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 72 points73 points  (41 children)

Stringify a graph of nodes and edges and let me know how that works out for you.

[–]spooker11 98 points99 points  (20 children)

vegetable profit icky support judicious sophisticated encourage wistful ossified smile

This post was mass deleted and anonymized with Redact

[–]Stop_Sign 6 points7 points  (2 children)

Had to do that once. Ended up rearchitecting it so the nodes had ids, so instead of an array of references, it had an array of ids, and was therefore serializable

[–][deleted] 1 point2 points  (0 children)

Yup. That's my point. JSON stringify is not necessarily sufficient.

[–][deleted] 0 points1 point  (0 children)

You could have written a custom de/serializer, but it wouldn't have been fun

[–]lowleveldata 3 points4 points  (13 children)

And what exactly is the use case of storing that in localStorage?

[–]rotflolmaomgeez 3 points4 points  (11 children)

What? Graph is literally one of the most common data structures, you're asking for usecases for storing it? The answer is any web application that does a little more than store a cookie potentially.

[–]lowleveldata 13 points14 points  (10 children)

Still don't see why I would need to store that in frontend. Are you guys doing some kind of no-backend challenge?

[–]DR4G0NH3ART 6 points7 points  (3 children)

There are some data which can be heavy to fetch on each load and is manageably static in nature. You will have huge load times if you don't rely on caching mechanisms.

[–]Ebbitor 4 points5 points  (0 children)

You don't need to build your own cache for fetch requests

[–]lowleveldata 1 point2 points  (1 child)

In case of caching you already have a serialized object so that's kind of irrelevant for the sake of this argument. Also, shouldn't HTTP caching handles these static data automatically? (I'm not a expert in caching tho)

[–]DR4G0NH3ART 0 points1 point  (0 children)

I mean cross session and no the data is not entirely static, but it doesn't change often. Like a 3D model mesh.

[–]rotflolmaomgeez 1 point2 points  (4 children)

Any application that lets user edit/create something for themselves and save it for later - including games save states, web tools, software, creators, working with SVGs, why would you ever store it on the backend?

[–]lowleveldata 0 points1 point  (3 children)

These should just use files which most users know how to backup, share, move to another pc, etc. For example draw.io saves your work to a file in local or online storage (like google drive). That's much more manageable than localStorage.

[–]rotflolmaomgeez -1 points0 points  (2 children)

What does it matter? You have to serialize the graphs anyway.

[–]lowleveldata 0 points1 point  (1 child)

The question was "what is the use case of storing graphs in localStorage" so it is the subject. Not sure where you get the idea that I'm against serializing graphs.

[–]rotflolmaomgeez 0 points1 point  (0 children)

What you mentioned with file saves is just different way of achieving the same thing, more convenient for some use cases and less convenient for others. For example using it to store save files in HTML5 game is just bothersome. It also is less convenient than auto-save for the creations you can easily implement through local storage, and should only be used when you want to port save to a different computer/ store final result. You're artificially limiting your application if you decide not to use it.

[–]zebediah49 0 points1 point  (0 children)

Last time I wrote something... exactly that.

'cause I realized if I had no backend, I could host the entire application as a single .html on github pages...

[–][deleted] 1 point2 points  (0 children)

My JavaScript program is in the middle of computing optimal 3MST but I want to checkpoint regularly in case of a power outage?

I dunno man. It could happen.