Skip to content

Commit

Permalink
more docs
Browse files Browse the repository at this point in the history
  • Loading branch information
marc2332 committed Sep 21, 2024
1 parent f690fa7 commit 3c09981
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 14 deletions.
6 changes: 5 additions & 1 deletion book/src/learn/animation.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,8 @@ fn app() -> Element {
background: "{color.read().as_string()}",
})
}
```
```

### Other examples

- [animation.rs](https://github.com/marc2332/freya/blob/main/examples/animation.rs)
3 changes: 1 addition & 2 deletions book/src/learn/async.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@

You may run asynchronous code through the different APIs Dioxus provide. You can use other libraries such as tokio to spawn tasks but it's not always the recommended approach as these will not work with the lifecycling of the components.

You can use these different APIs:

### `spawn`

Simple function to spawn an async task, this is primarily targeted for custom hooks or when you wanted to run some async code dinamically from an event listener.
Simple function to spawn an **async task**, this is primarily targeted for custom hooks or when you wanted to run some async code dinamically from an event listener.

Important to know: Tasks spawned with `spawn` will be cancelled when the component their were created is dropped. If you want to have an async tasks not attached to the component you may use `spawn_forever`.

Expand Down
4 changes: 2 additions & 2 deletions book/src/learn/built_in_components.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Built-in Components

Freya comes with a set of styled and functional components you may use to develop faster. Some examples as `Button`, `Switch`, `Scrollview`, etc.
Freya comes with a set of styled and functional components you may use to develop faster. Some examples are `Button`, `Switch`, `Scrollview`, etc.

You can find more about them in [their docs](https://docs.rs/freya-components).
You can find more about them in the [API Reference](https://docs.rs/freya-components).

Example:
```rs
Expand Down
18 changes: 9 additions & 9 deletions book/src/learn/router.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@ Freya supports the official [Dioxus Router](https://docs.rs/dioxus-router/latest
Example:
```rs
fn app() -> Element {
/// We place the router renderer in the root component
rsx!(Router::<Route> {})
}

/// Declare your Routes tree in an enum
/// Every route must have a component with the same name
/// So for example, `Home` needs to have a `fn Home(...` component
/// the `Routable` macro will pick it up automatically
/// so it must be in the scope.
// Declare your Routes tree as an enum
// Every route must have a component with the same name
// So for example, `Home` needs to have a `fn Home(...` component
// the `Routable` macro will pick it up automatically
// so it must be in the scope.
#[derive(Routable, Clone, PartialEq)]
#[rustfmt::skip]
pub enum Route {
Expand All @@ -26,7 +27,9 @@ pub enum Route {
PageNotFound { }, // Handle 404 routes.
}

#[allow(non_snake_case)]
// This component is used as container for the router (as it was marked with `#[layout(AppSidebar)]`), which means
// That we can render something here that will be rendered no matter what route you are in
// Useful for navigation bars.
fn AppSidebar() -> Element {
rsx!(
Body {
Expand Down Expand Up @@ -55,7 +58,6 @@ fn AppSidebar() -> Element {
)
}

#[allow(non_snake_case)]
#[component]
fn Home() -> Element {
rsx!(
Expand All @@ -65,7 +67,6 @@ fn Home() -> Element {
)
}

#[allow(non_snake_case)]
#[component]
fn Other() -> Element {
rsx!(
Expand All @@ -75,7 +76,6 @@ fn Other() -> Element {
)
}

#[allow(non_snake_case)]
#[component]
fn PageNotFound() -> Element {
rsx!(
Expand Down

0 comments on commit 3c09981

Please sign in to comment.