Svelte: If the REPL can keep its content, it'd be great to send other people sample code

Created on 5 Feb 2020  Â·  7Comments  Â·  Source: sveltejs/svelte

Right now if I have some code sample on the Svelte REPL, I can send people some code samples:

https://svelte.dev/repl/64635232b5784bfa8997192ced12acd4?version=3.18.1

but if I forgot and a few days later come back and edited some code to experiment and saved it and didn't save a good version at the end, or just experimented with it and saved some bad code and then fork another version, now the version I sent to other people won't work any more.

Can it act somewhat like jsfiddle, so that a version of sample code, some URL like:

https://svelte.dev/repl/64635232b5784bfa8997192ced12acd4/12?version=3.18.1

(URL won't work, just a sample) So that the 12 is the minor version? So I can send to other people version 01 or 03, and I can keep on editing the code into version 4, 5, 6, 7 and it won't affect the version I sent to people?

Otherwise, I can in a few days, forgot that I sent to other people and edit that version. It'd fine if I fork another version and never touch that original version, but sometimes which URL is which might be forgotten and the original version is used and edited.

proposal REPL pending clarification

All 7 comments

it is true that I can fork another page B and just work on that page B. But there are times I have bookmarks in my browser, or that I kept a code sample and its REPL URL in my Google docs. So I might re-visit a page without knowing that I should not modify it because 12 days ago, I sent it to somebody.

It would take a decent amount of work to implement version-awareness with a decent UI in the REPL. I suspect that if it were well-implemented, that functionality would be accepted, but I think you'd have to be the one to implement it.

Things to consider:

  • you would want to show "there's a newer version of this code" to someone viewing an older version
  • you would need to list all versions/changes to a given REPL app somewhere

In the meantime, the way that I personally mitigate that kind of risk is by giving my REPL apps a name before linking to them from somewhere else. That way you have a clue as to whether or not an old REPL might be risky to change.

Couldn't this be solved with a permalink to a REPL for this precise version of the code?

You use this for sharing and no problem if you break everything afterward.

Indeed, a notification that a newer version of the code exists would be a nice to have ("it might be better, worse, or completely different ¯\_(ツ)_/¯").

The REPL used to have every saved version be a permalink. The behavior changed when the REPL switched from storing code on Gist to storing it in a database. Some people seemed fairly happy with the change in behavior, so it would probably be tough to convince everyone to switch back to the all-permalink-all-the-time implementation.

But like I said, if you're willing to implement a multiple-version-aware version of the REPL with good UI, you could probably get folks on board.

I'd definitely be into that if we can come up with a good way to convey 'copy this link to share this version, copy this link to share whatever future versions you might make'.

maybe you could just have a lock button ("lock this code") and when you click on it the code will be saved in a different place and the "locked" pages will still be editable but they won't auto-save.

because this is different behavior you could do

// Enable navigation prompt
window.onbeforeunload = function() {
    return true;
};
// Remove navigation prompt
window.onbeforeunload = null;

to make sure people know that the code is read only

I've seen various editors use an URL like: https://host/slug/version
So:
https://svelte.dev/repl/15200f778a624c66b59dc53b6d8f3b3c/0?version=3.20.0
is the original save,
https://svelte.dev/repl/15200f778a624c66b59dc53b6d8f3b3c/1?version=3.20.0
will be the second save
https://svelte.dev/repl/15200f778a624c66b59dc53b6d8f3b3c/2?version=3.20.0
is the next save, etc.

multiple-version-aware version of the REPL with good UI,

Just a dropdown of all the save versions would be the first round IMHO.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sskyy picture sskyy  Â·  3Comments

clitetailor picture clitetailor  Â·  3Comments

angelozehr picture angelozehr  Â·  3Comments

robnagler picture robnagler  Â·  3Comments

thoughtspile picture thoughtspile  Â·  3Comments