cyclejs / cyclejs

A functional and reactive JavaScript framework for predictable code
http://cycle.js.org
MIT License
10.24k stars 420 forks source link

Host the examples #469

Open bogas04 opened 7 years ago

bogas04 commented 7 years ago

I feel that it'll be easier for users to understand, test and play with CycleJS if the examples are hosted somewhere. Something like how react-router 4 does. Currently only such thing is the example on homepage.

One great way to start doing this can be simply creating bins on webpackbin.com. All your examples use 2-3 files, and don't rely too much on build processes other than that of babel.

Frikki commented 7 years ago

webpackbin is highly unstable.

Widdershin commented 7 years ago

We could adapt tricycle for this sort of thing. Could be tied in with create-cycle-app perhaps https://github.com/cyclejs-community/create-cycle-app/issues/10

staltz commented 7 years ago

I agree. It would be nice. It's not my priority, but something someone can help contribute.

geovanisouza92 commented 7 years ago

Can I propose something? What about point every project on examples/ to a Code Sandbox, embedding them on the docs/site? Sandbox would download dependencies and run the code on the browser, totally synced with the repo, with a project script to keep all examples linked seamlessly.

To achieve this, the only required change is to 1) rename each example main.js to index.js, following the convention expected by CS, or; 2) point the main on each example package.json.

If you are ok with that, I can make a PR :smiley:

staltz commented 7 years ago

@geovanisouza92 I'm not familiar with Code Sandbox, it looks good, I'm just worried about the limits of the free plan, and whether this startup will last long enough. I was also excited about putting each example in Dat, this way it's very easy to update them and view them in Beaker browser. To make it available also for users of the old web, we could use https://hashbase.io/ (it also has a pricing plan, but at least it's easy to self host if we decide so).

bogas04 commented 7 years ago

I can migrate them to CSB as an experiment.

Here are 2:

It's very basic and easy.

If you dig this, I can take out some time tomorrow and migrate all the remaining ones.

@staltz

eostrom commented 5 years ago

CodeSandbox is still around and has made this even easier, at least for the example I tried: https://codesandbox.io/s/github/eostrom/cyclejs/tree/code-sandbox-demo/examples/advanced/animated-letters

This is all I did:

  1. Fork this repo on GitHub.
  2. Add a main property to the example's package.json, pointing to src/main.js.
  3. Copy the URL for the animated-letters subdirectory of my GitHub repo.
  4. Paste it into CodeSandbox's import wizard.

CodeSandbox will also watch the GitHub repo and update itself automatically when it changes! This is great – if we just copy-pasted code to a sandbox, it would quickly fall out of date unless someone was dedicated to maintaining it.

Note that this sandbox is not "owned" by anyone, as far as I can tell. If you try to edit it, it will automatically create a private copy of the sandbox.

With all that in mind, if there's still interest in this, I propose the following:

  1. I will add main properties to all the examples.
  2. If needed, I will make other changes to make the examples run on CodeSandbox, making sure they also still run in a development environment.
  3. I will submit a pull request with these changes.
  4. Once that's merged, I will create a CodeSandbox for each example, imported from the master branch of the main @cyclejs repo so that it keeps up with future changes.
  5. Ideally, someone with access to https://cycle.js.org/ will link to these sandboxes so visitors know they exist.

Let me know if this seems like a good way to proceed.

eostrom commented 5 years ago

A progress report on this (with links to the sandboxes):

The other 12 examples work!

I'll look further into these failures, but if anyone else wants to jump in, feel free to fork a copy of the example and tinker with it.