New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Autosaving & autoloading #2
Conversation
public/main.js
Outdated
} | ||
} | ||
|
||
window.onunload = function () | ||
{ | ||
// Save the graph when unloading the page | ||
localStorage.setItem('graph', exportData()); | ||
localStorage.setItem('model', model.serialize()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should probably call the value in the local storage 'project' or 'state', seems more descriptive.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps latestModelState
, just in case other aspects of the project require state later on (UI configurations, maybe)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Having latestModelState
= {state: ...}
felt redundant, I went with latestModelData
instead. Still cool with you?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can tell that you are an experienced programmer by how quickly you are able to jump in.
I added a few comments, I hope you can forgive my nitpicking. You did a good job.
For the next step, I would like to add "Open" and "Save" links in the top bar to the right of "New" and connect those with file pickers. I would prefer we put the code that deals with the buttons and file picking in main.js
since it's more to do with UI than the mechanics of the model.
Thank you. You made a great foundation to navigate through -- Thanks for that too! Nitpick as critically as you'd like, nothing personal at all. I'll adapt to your preferences and wants for the project. I'll update this PR with requested changes and start a new PR for the Open/Save portion. |
a4e9062
to
ef93697
Compare
Persistence works well on my end, and the "New" button works too. Good job 👍 |
This looks like a good prerequisite for importing and exporting to disk.
Includes some new utilities (
isString
,isObject
). Tried to match the existing coding style, do let me know if I missed anything.