Skip to content

Commit

Permalink
docs: Incoperate changes from pre-release branch
Browse files Browse the repository at this point in the history
  • Loading branch information
marcoroth committed Mar 14, 2023
1 parent e965b79 commit 9ade91b
Show file tree
Hide file tree
Showing 15 changed files with 175 additions and 123 deletions.
4 changes: 2 additions & 2 deletions docs/appendices/deployment.md
Expand Up @@ -141,7 +141,7 @@ In a more sophisticated setup, you could experiment with hosting your websockets
Specifically, if you experience your server process appear to freeze up when ActionCable is in play, you need to make sure that your `nginx.conf` has the **port 443 section** set up to receive secure websockets:

::: code-group
```text [/etc/nginx/nginx.conf]
```txt [/etc/nginx/nginx.conf]
server {
listen 443;
passenger_enabled on;
Expand Down Expand Up @@ -273,7 +273,7 @@ end

On the face, serving raw HTML to the client means a smaller download, there's no SPA dynamically rendering a page from JSON (slow) and draining the battery. However, the question deserves a more nuanced treatment - and not just because **some devices might not even support Websockets**.

It's simply true that the team developing StimulusReflex is working on relatively recent, non-mobile computers with subjectively fast, reliable connections to the internet. None of us are actively testing on legacy hardware.
It's true that the team developing StimulusReflex is working on relatively recent, non-mobile computers with subjectively fast, reliable connections to the internet. None of us are actively testing on legacy hardware.

Raw Websockets has more in common with UDP than TCP, in that there's no retry logic or acknowledgement of delivery. Messages can arrive out of order, or not at all.

Expand Down
2 changes: 1 addition & 1 deletion docs/appendices/glossary.md
Expand Up @@ -6,7 +6,7 @@ The name of this project. It has a JS client and a Ruby based server component t

## Stimulus

An incredibly simple yet powerful JS framework by the creators of Rails.
A powerful JavaScript framework by the creators of Rails.

## "a Reflex"

Expand Down
6 changes: 3 additions & 3 deletions docs/appendices/troubleshooting.md
Expand Up @@ -452,7 +452,7 @@ Do you have any more weird edge cases? Please let us know!

## Open Issues

There are some things that we'd very much like to fix, but we simply haven't been able to or the responsibility falls to an upstream dependency we don't have direct access to.
There are some things that we'd very much like to fix, but we haven't been able to or the responsibility falls to an upstream dependency we don't have direct access to.

#### iframe gets refreshed despite `data-reflex-permanent`

Expand Down Expand Up @@ -558,7 +558,8 @@ If your `data-reflex-permanent` isn't being respected, try adding a unique `id`
StimulusReflex works best with Webpacker v5.4.
:::

::: info
## The `spring` gem can be troublesome

If _something_ goes wrong, it's often because of the **spring** gem. 💣👎

You can test this by temporarily setting the `DISABLE_SPRING=1` environment variable and restarting your server.
Expand All @@ -569,7 +570,6 @@ To remove spring **forever**, here is the process we recommend:
2. Edit your Gemfile and comment out **spring** and **spring-watcher-listen**
3. `bin/spring binstub --remove --all`
4. Comment out the line in `bin/rails` which says: `load File.expandpath("spring", _dir)`
:::

## Be realistic

Expand Down
2 changes: 1 addition & 1 deletion docs/guide/authentication.md
Expand Up @@ -157,7 +157,7 @@ end
### Tokens (Subscription-based)

::: info
You can clone [a simple but fully functioning example application](https://github.com/leastbad/stimulus_reflex_harness/tree/token_auth) based on the Stimulus Reflex Harness. It uses Devise with the `devise-jwt` gem to create a JWT token which is injected into the HEAD. You can use it as a reference for all of the instructions below.
You can clone [a bare bones but fully functioning example application](https://github.com/leastbad/stimulus_reflex_harness/tree/token_auth) based on the Stimulus Reflex Harness. It uses Devise with the `devise-jwt` gem to create a JWT token which is injected into the HEAD. You can use it as a reference for all of the instructions below.
:::

There are scenarios where developers might wish to use JWT or some other form of authenticated programmatic access to an application using websockets. For example, you can configure a GraphQL service to accept queries over ActionCable instead of providing an URL endpoint for traditional Ajax calls. You also might need to support multiple custom domains with one ActionCable endpoint. You might also need a solution that doesn't depend on cookies, such as when you want to deploy multiple AnyCable nodes on a service like Heroku.
Expand Down
10 changes: 5 additions & 5 deletions docs/guide/cableready.md
Expand Up @@ -7,16 +7,16 @@
| StimulusReflex | Translates user actions into server-side events that change your data, then regenerating your page based on this new data **into an HTML string**. |
| CableReady | Takes the HTML string from StimulusReflex and sends it to the browser before using [`morphdom`](https://github.com/patrick-steele-idem/morphdom/) to update only the parts of your DOM that changed. |

⬆️ StimulusReflex is for **sending** commands. 📡\
⬇️ CableReady is for **receiving** updates. 👽
⬆️ StimulusReflex is for sending commands to the server. 📡
⬇️ CableReady is for sending commands to the browser. 👽

::: info
A Reflex action is a reaction to a user action that changes server-side state and re-renders the current page (or a subset of the current page) for that particular user in the background, provided that they are still on the same page.

A CableReady method is a reaction to some server-side code (which must be imperatively called) that makes some change for some set of users in the background.
:::

CableReady has 36 operations for changing every aspect of your page, and you can define your own. It can emit events, set cookies, make you breakfast and call your parents (Twilio fees are not included.)
CableReady has a bunch of operations for changing every aspect of your page, and you can define your own. It can emit events, set cookies, and much more.

[![](https://img.youtube.com/vi/dPzv2qsj5L8/maxresdefault.jpg)](https://www.youtube.com/watch?v=dPzv2qsj5L8)

Expand Down Expand Up @@ -57,7 +57,7 @@ Do not include `CableReady::Broadcaster` in your Reflex classes. It's already pr

Since StimulusReflex uses CableReady's `morph` and `inner_html` operations, you might be wondering when or if to just use CableReady operations directly instead of calling StimulusReflex's `morph`.

The simple answer is that you should use StimulusReflex when you need life-cycle management; callbacks, events and promises. Reflexes have a transactional life-cycle, where each one is assigned a UUID and the client will have the opportunity to respond if something goes wrong.
The answer is that you should use StimulusReflex when you need life-cycle management; callbacks, events and promises. Reflexes have a transactional life-cycle, where each one is assigned a UUID and the client will have the opportunity to respond if something goes wrong.

CableReady operations raise their own events, but StimulusReflex won't know if they are successful or not. Any CableReady operations you broadcast in a Reflex will be executed immediately.

Expand All @@ -69,7 +69,7 @@ You can control the order in which CableReady and StimulusReflex operations exec
2. StimulusReflex `morph` operations
3. CableReady operations that haven't been `broadcast`ed

CableReady operations that have `broadcast` called on them well be immediately delivered to the client, while any CableReady operations queued in a Page or Selector Morph Reflex action that aren't broadcast by the end of the action will be broadcast along with the StimulusReflex-specific `morph` operations. The StimulusReflex operations execute first, followed by any remaining CableReady operations.
CableReady operations that have `broadcast` called on them will be immediately delivered to the client, while any CableReady operations queued in a Page or Selector Morph Reflex action that aren't broadcast by the end of the action will be broadcast along with the StimulusReflex-specific `morph` operations. The StimulusReflex operations execute first, followed by any remaining CableReady operations.

::: info
If you have CableReady operations that haven't been broadcasted followed by another set of operations that do get broadcasted... the former group of operations will go out with the latter. If you want some operations to be sent with the StimulusReflex operations, make sure that they occur after any calls to `broadcast`.
Expand Down

0 comments on commit 9ade91b

Please sign in to comment.