mirror of
https://github.com/robertwayne/axum-htmx
synced 2025-12-18 13:45:17 +01:00
Update docs to specify response parts ordering (fixes #11)
This commit is contained in:
parent
1edbce34be
commit
e8a0b94d03
2 changed files with 17 additions and 4 deletions
12
README.md
12
README.md
|
|
@ -130,10 +130,12 @@ trigger](https://htmx.org/attributes/hx-trigger/) header.
|
|||
use axum_htmx::HxResponseTrigger;
|
||||
|
||||
// When we load our page, we will trigger any event listeners for "my-event.
|
||||
async fn index() -> (&'static str, HxResponseTrigger) {
|
||||
async fn index() -> (HxResponseTrigger, &'static str) {
|
||||
// Note: As HxResponseTrigger only implements `IntoResponseParts`, we must
|
||||
// return our trigger first here.
|
||||
(
|
||||
"Hello, world!",
|
||||
HxResponseTrigger::normal(["my-event", "second-event"]),
|
||||
"Hello, world!",
|
||||
)
|
||||
}
|
||||
```
|
||||
|
|
@ -148,7 +150,7 @@ use serde_json::json;
|
|||
// instead of the root module.
|
||||
use axum_htmx::{HxEvent, HxResponseTrigger};
|
||||
|
||||
async fn index() -> (&'static str, HxResponseTrigger) {
|
||||
async fn index() -> (HxResponseTrigger, &'static str) {
|
||||
let event = HxEvent::new_with_data(
|
||||
"my-event",
|
||||
// May be any object that implements `serde::Serialize`
|
||||
|
|
@ -159,7 +161,9 @@ async fn index() -> (&'static str, HxResponseTrigger) {
|
|||
)
|
||||
.unwrap();
|
||||
|
||||
("Hello, world!", HxResponseTrigger::normal([event]))
|
||||
// Note: As HxResponseTrigger only implements `IntoResponseParts`, we must
|
||||
// return our trigger first here.
|
||||
(HxResponseTrigger::normal([event]), "Hello, world!")
|
||||
}
|
||||
```
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue