Skip to content

Commit c3f2a02

Browse files
committed
docs: added some missing lang declarations
1 parent 108b754 commit c3f2a02

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

docs/next/en-US/state/freezing-thawing.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ You can control many aspects of thawing, including whether frozen state or new s
2222

2323
Here's a more complex example of using state freezing. There are two inputs, one for the global state, and one for the page state, which will be used to reactively set them, and then a button that freezes the whole app (using the `reactor.freeze()` method, which really is all you need to do!). For demonstration purposes, that's then synchronized to an input that takes in state that can be used to thaw the app, which is a slightly more complex (and fallible) process. Note the use of `#[cfg(client)]`, since state freezing/thawing can only take place on the client-side.
2424

25-
```
25+
```rust
2626
{{#include ../../../examples/core/freezing_and_thawing/src/templates/index.rs}}
2727
```
2828

docs/next/en-US/state/manual.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ Be sure to derive `Clone` on this type.
2929

3030
The [`MakeRx`](=state/trait.MakeRx@perseus) trait is the backbone of the Perseus reactive state platform, but it's actually surprisingly simply to implement! All you need to do is something like this:
3131

32-
```
32+
```rust
3333
impl MakeRx for MyState {
3434
type Rx = MyStateRx;
3535
fn make_rx(self) -> Self::Rx {
@@ -44,15 +44,15 @@ Usually, the body of that `make_rx()` function will be simply wrapping all the e
4444

4545
The [`MakeUnrx`](=state/trait.MakeUnrx@perseus) trait is slightly more complicated, because it involves converting out of `RcSignal`s, and also the suspense system. Like `MakeRx`, there is an associated type `Unrx`, which should just reference your unreactive state type (which must implement `Serialize + Deserialize + MakeRx`). For nested reactive fields, you can simply call `.make_unrx()` to make them unreactive, whereas non-nested fields will need something like this:
4646

47-
```
47+
```rust
4848
(*self.my_field.get_untracked()).clone()
4949
```
5050

5151
The trickiest part of this is the `compute_suspense()` function (which must be target-gated as `#[cfg(client)]`). If you're not using [suspended state](:state/suspense), you can safely leave the body of this completely empty, but if you are, you'll need to get acquainted with the [`compute_suspense`](=state/fn.compute_suspense@perseus) and [`compute_suspense_nested`](=state/fn.compute_suspense_nested@perseus) functions. These simply take the provided Sycamore reactive scope, a clone of the reactive field, and then the future returned by your suspense handler.
5252

5353
The most complex part of this is the suspense handler, because you want to call the function, but not `.await` on it, meaning the future can be handled by Perseus appropriately. To do this, you'll want to call your handler like this:
5454

55-
```
55+
```rust
5656
my_handler(
5757
cx,
5858
create_ref(cx, self.my_field.clone())
@@ -65,7 +65,7 @@ Notice how `create_ref()` is used on the field, which produces a reference scope
6565

6666
Once youv've done `MakeUnrx`, you're over the hump, and now you can pretty much just copy this code, substituting in the names of your state types of course:
6767

68-
```
68+
```rust
6969
impl Freeze for MyStateRx {
7070
fn freeze(&self) -> String {
7171
use perseus::state::MakeUnrx;

0 commit comments

Comments
 (0)