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
pub fn complex_form_test() -> Node<Msg> { | |
let (_form_state, ctl) = use_form_state_builder::<Msg>() | |
.on_blur(|form_state| { | |
log!("Outputing the form state on blur due to the #on_blur closure"); | |
log!(form_state); | |
}) | |
.build(); | |
div![ | |
div![ |
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
fn hook_style_input() -> Node<Msg> { | |
let (mut input_string, string_access) = use_state(|| "".to_string()); | |
if input_string == "Seed" { | |
input_string = "is pretty cool!".to_string(); | |
} | |
div![ | |
"Try typing 'Seed'", | |
input![ | |
attrs! {At::Type => "text", At::Value => input_string}, |
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
pub fn view() -> Node<Msg> { | |
let graphql_query = "{countries {name currency emoji}}"; | |
let graphql_url = "https://countries.trevorblades.com/"; | |
let container_name = "countries"; | |
// GraphQL List hook, manages fetching data and keeping list up to date. | |
let (list, graphql_control) = | |
use_graphql_list::<Country>(graphql_query, graphql_url, container_name); | |
div![ |
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
use super::{Model, Msg}; | |
use enclose::enclose as e; | |
use seed::{prelude::*, *}; | |
use seed_comp_helpers::graphql_list::use_graphql_list; | |
use seed_comp_helpers::on_click; | |
use serde::Deserialize; | |
#[derive(Clone, Debug, Deserialize)] | |
pub struct Country { | |
name: String, |
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
use slotmap::{new_key_type, SlotMap}; | |
// Enables a slotmap to use a typed key unique to Unit. | |
new_key_type! {struct UnitKey;} | |
#[derive(Copy, Clone, Debug)] | |
struct Unit { | |
health: i32, | |
attack_strength: i32, | |
id: UnitKey, //enables unique identification of units for mutation by owning grid. |
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
#[derive(Clone, Debug, Deserialize)] | |
struct Todo { | |
userId: u32, | |
id: u32, | |
title: String, | |
completed: bool, | |
} | |
... |
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
#[topo::nested] | |
fn two_way_components_example() -> Node<Msg> { | |
// two way communication between two compoments | |
// we need an accessor that can hold two access states. | |
// after this is passed to peer compoments this is then updated with reference | |
// to all peers | |
let (_state, shared_channel_access): ((StateAccess<String>, StateAccess<String>), _) = | |
use_state(|| { | |
let id = topo::Id::current(); |