-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
localStorage support. #77
Conversation
A check for the existence of localStorage would be good to support browsers that don't have it. |
@sebmck Added a |
@hemanth Bit overkill. I was suggesting more |
@sebmck Duh! yeah, I was overwhelmed by mayBe, heh heh, reverting it to a simpler version. |
@sebmck Done 🐱 |
@hemanth Could you actually clean up these commits by rebasing your commit onto the latest master? |
@sparty02 Thanks, i'm aware of it, I fetched and merged your branch, hence the older commits have appeared. |
@thejameskyle Done. |
@@ -109,6 +109,10 @@ | |||
var state = UriUtils.parseQuery(); | |||
this.options = _.assign(new Options(), state); | |||
|
|||
if (window.localStorage) { |
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.
@hemanth You may want to move the local storage call up above where options are set on the repl instance:
this.options = _.assign(new Options(), state);
(so that options can be persisted too).
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.
👍
@sparty02 Done :)
Local storage is an interesting idea, but I wonder if it would be confusing at all if a user came back to the site and there was all of a sudden input (via local storage) in their REPL. I definitely think persisting options is nice, I'm just concerned about how to effectively persist the code. I'm almost wondering if this should be beefed up into some kind of "save session for later" feature (which could key into local storage by ID). This could then be pulled up via a menu. Note, if it was taken this far, this could tie into #59 (via how to seed the REPL input from a dropdown) and #66 (the idea of 'saving' a session for later in a more robust way) Just some thoughts...... |
@sparty02 I would vote to get this rolling first and improvise later? I have come across few online REPLs that save the previous code as is and is not confusing, maybe we must roll and wait for feedback from users? |
Note |
It's probably fine to just wrap these in try-catch blocks. @hemanth mind doing that? |
This is what I usually do, yeah. |
@thejameskyle No other options left, I had created a MayBe monad :D which was an overkill :) |
No other go for now.
I would just leave it as a try-catch try {
state = JSON.parse(localStorage.getItem('replState'));
} catch(e) {} |
@thejameskyle Done. |
Thanks! |
Thank you! |
@thejameskyle First cut. Let me know if this approach is OK with you. WRT #71