diff options
author | Giacomo Cavalieri <giacomo.cavalieri@icloud.com> | 2024-04-02 10:09:15 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-02 09:09:15 +0100 |
commit | e2b57b8e6150f824edbf044fd6222f0c81d6f1b3 (patch) | |
tree | 931e5661180000395554492dee5c2cbe70e48fb7 /pages/guide/03-side-effects.md | |
parent | bbefb97ba3d8f117b8cbef769180a4d8425cf145 (diff) | |
download | lustre-e2b57b8e6150f824edbf044fd6222f0c81d6f1b3.tar.gz lustre-e2b57b8e6150f824edbf044fd6222f0c81d6f1b3.zip |
:memo: Fix some typos. (#97)
Diffstat (limited to 'pages/guide/03-side-effects.md')
-rw-r--r-- | pages/guide/03-side-effects.md | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/pages/guide/03-side-effects.md b/pages/guide/03-side-effects.md index f7ab3de..5306408 100644 --- a/pages/guide/03-side-effects.md +++ b/pages/guide/03-side-effects.md @@ -35,7 +35,7 @@ this: Well what does managed effects mean, exactly? In Lustre, we expect your `init`, `update`, and `view` functions to be [_pure_](https://github.com/lustre-labs/lustre/blob/main/pages/hints/pure-functions.md). -That means they shouldn't perform side effects like making a HTTP request or writing +That means they shouldn't perform side effects like making an HTTP request or writing to local storage: we should be able to run your functions 100 times with the same input and get the same output every time! @@ -43,13 +43,13 @@ Of course, in real applications performing HTTP requests and writing to local storage turn out to be quite useful things to do. If we shouldn't perform side effects in our code how do we do them then? Lustre has an [`Effect`](https://hexdocs.pm/lustre/lustre/effect.html) type that _tells the runtime what side effects to perform_. So we say "Hey, I -want to make a HTTP request to this URL and when you get the response, dispatch +want to make an HTTP request to this URL and when you get the response, dispatch this message to me". The runtime takes care of performing the side effect and turning the result into something our `update` function understands. ## Why managed effects? -This can feel like a lot of ceremony to go through just to make a HTTP request. +This can feel like a lot of ceremony to go through just to make an HTTP request. The natural question is: why not just let us make these requests ourselves? Managed effects have a number of benefits that come from _separating our programs @@ -189,7 +189,7 @@ call to ensure the DOM has had a chance to update first. So far, we have seen side effects that are expected to _return something_ to our program. If we fire an HTTP request, it wouldn't be much use if we couldn't get the response back! Sometimes folks wrongly assume effects _must_ use the `dispatch` -function their given, but this isn't true! +function they're given, but this isn't true! It's also totally valid to write effects that don't dispatch any messages. Earlier we saw an example of how to read from local storage, we might also want an effect |