-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* improved context API docs, added example of struct component context producer * forgot to commit that oops
- Loading branch information
1 parent
954b0ec
commit a2786b1
Showing
7 changed files
with
66 additions
and
18 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
use yew::prelude::*; | ||
|
||
use super::msg_ctx::MessageContext; | ||
|
||
pub struct StructComponentProducer; | ||
|
||
impl Component for StructComponentProducer { | ||
type Message = (); | ||
type Properties = (); | ||
|
||
fn create(_ctx: &Context<Self>) -> Self { | ||
Self | ||
} | ||
|
||
fn view(&self, ctx: &Context<Self>) -> Html { | ||
let (msg_ctx, _) = ctx | ||
.link() | ||
.context::<MessageContext>(Callback::noop()) | ||
.expect("No Message Context Provided"); | ||
|
||
html! { | ||
<button onclick={move |_| msg_ctx.dispatch("Other message received.".to_owned())}> | ||
{"OR ME"} | ||
</button> | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters