text
stringlengths
14
100k
source
stringclasses
1 value
repo
stringclasses
810 values
language
stringclasses
13 values
<|fim_suffix|> } State { entries, filter: self.filter, } .into() } Action::ClearCompleted => { let mut entries = self.entries.clone(); entries.retain(|e| Filter::Act...
fim
yewstack/yew
rust
<|fim_prefix|>use std::error::Error; use std::fmt::{self, Debug, Display, Formatter}; use wasm_bindgen::JsCast; use wasm_bindgen::prelude::*; use wasm_bindgen_futures::JsFuture; use web_sys::{Request, RequestInit, RequestMode, Response}; use yew::{Component, Context, Html, html}; mod markdown; const MARKDOWN_URL: &s...
fim
yewstack/yew
rust
<|fim_suffix|>ft => { tag.add_attribute("class", "text-left"); } Alignment::Center => { tag.add_attribute("class", "text-center"); } Alignment::Right => { tag.add_attri...
fim
yewstack/yew
rust
<|fim_suffix|>(idx % range + range) % range) as usize // because % has sign of dividend } <|fim_prefix|>use rand::RngExt; pub struct Conway { pub cellules: Vec<bool>, pub width: usize, pub height: usi<|fim_middle|>ze, } impl Conway { pub fn new(width: usize, height: usize) -> Self { Self { ...
fim
yewstack/yew
rust
<|fim_suffix|> <div class={classes!("game-cellule", if self.conway.alive(row, col) {"cellule-live"} else {"cellule-dead"})} onclick={ctx.link().callback(move |_| Msg::ToggleCellule((row,col)))}> </div> ...
fim
yewstack/yew
rust
<|fim_prefix|>use implicit_clone::unsync::*; use wasm_bindgen::{JsCast, UnwrapThrowExt}; use web_sys::{HtmlInputElement, KeyboardEvent}; use yew::prelude::*; #[derive(Properties, PartialEq)] struct FolksViewP<|fim_suffix|>o:"}</p> <ul> for s in props.folks.iter() { <li>{s}</li> } ...
fim
yewstack/yew
rust
<|fim_prefix|>mod array; mod map; mod string; use yew::prelude::*; use self::array::*; use self::map::*; use self::string::*; #[function_component] fn App() -> Html { html! { <h1>{ "IString Example" }</h1> <StringExample /> <hr/> <h1>{ "IArray Example" }</h1> <ArrayExample...
fim
yewstack/yew
rust
<|fim_suffix|> } else { MapExampleMessage::Noop } }); html! { <h2>{"Input"}</h2> <input {onkeyup} /> <h2>{"Output"}</h2> <Display values={&self.values} /> } } } <|fim_prefix|>use implicit_clone::unsync::*; use was...
fim
yewstack/yew
rust
<|fim_suffix|> name: "World".into(), } } fn update(&mut self, _: &Context<Self>, msg: Self::Message) -> bool { match msg { StringExampleMessage::UpdateName(name) => { self.name = name.into(); true } } } fn view(...
fim
yewstack/yew
rust
<|fim_prefix|>use yew::{Component, Context, Html}; const HTML: &str = include_str!("document.html"); pub struct App; impl Component for App { type Mess<|fim_suffix|>in() { yew::Renderer::<App>::new().render(); } <|fim_middle|>age = (); type Properties = (); fn create(_ctx: &Context<Self>) -> Self { ...
fim
yewstack/yew
rust
<|fim_suffix|> return "very important message" } <|fim_prefix|>export function h<|fim_middle|>ello() {<|endoftext|>
fim
yewstack/yew
javascript
<|fim_prefix|>expor<|fim_suffix|>ction bye() { return "unimportant message" } <|fim_middle|>t fun<|endoftext|>
fim
yewstack/yew
javascript
<|fim_prefix|>use wasm_bindgen::prelude::*; // https://github.com/rustwasm/wasm-bindgen/issues/3208 #[wasm_bindgen(inline_js = "export function import2(path) { return import(path); }")] unsafe extern "C" { // this should be in js-sys but is not. see https://github.com/rustwasm/wasm-bindgen/issues/2865 // pub f...
fim
yewstack/yew
rust
<|fim_suffix|>map(|path| format!("{path}/js/unimp.js")) .unwrap(); let s = use_future(|| async move { let promise = bindings::import(&path); let module = JsFuture::from(promise).await.unwrap_throw(); let module = module.unchecked_into::<bindings::UnimpModule>(); module.bye() ...
fim
yewstack/yew
rust
<|fim_suffix|>>")); let joined = split.join(""); drop(index_html); let mut index_html = fs::File::options() .write(true) .truncate(true) .open(format!("{stage_dir}/index.html")) .expect("can't open index.html"); index_html .write_all(joined.as_ref()) .expe...
fim
yewstack/yew
rust
<|fim_suffix|> <div class="col"> <button class="btn_size alert alert-success" onclick={link.callback(|_| Msg::CreatePersons(1))}> { "Create 1" } </button> </div> <div class="col"> <button class="btn_size ale...
fim
yewstack/yew
rust
<|fim_prefix|>use std::rc::Rc; use fake::Fake; use fake::faker::address::raw::*; use fake::faker::name::raw::*; use fake::locales::*; use yew::{Component, Context, Html, Properties, html}; <|fim_suffix|>elf { Self::Inline(info) => info, Self::Component(info) => info, } } pub fn...
fim
yewstack/yew
rust
<|fim_suffix|>(a, b)` such that `a < b`. match items.len() { 0 | 1 => return None, _ => { let indexes = rand::seq::index::sample(&mut rand::rng(), items.len(), 2); let (a, b) = (indexes.index(0), indexes.index(1)); if a < b { (a, b) } else ...
fim
yewstack/yew
rust
<|fim_suffix|>hars().rev().collect::<String>() }</p> </div> } } } fn create_canvas(document: &Document) -> HtmlCanvasElement { let canvas = HtmlCanvasElement::from(JsValue::from(document.create_element("canvas").unwrap())); canvas.set_width(100); canvas.set_height(100); let ctx ...
fim
yewstack/yew
rust
<|fim_prefix|>use std::iter; use yew::prelude::*; use super::header::ListHeader; use super::item::ListItem; use super::list::List; use super::{Hovered, WeakComponentLink}; pub enum Msg { Hover(Hovered), } pub struct App { hovered: Hovered, list_link: WeakComponentLink<List>, sub_list_link: WeakCompo...
fim
yewstack/yew
rust
use yew::prelude::*; use super::list::{List, Msg as ListMsg}; use super::{Hovered, WeakComponentLink}; #[derive(Clone, PartialEq, Properties)] pub struct Props { pub on_hover: Callback<Hovered>, pub text: String, pub list_link: WeakComponentLink<List>, } pub struct ListHeader; impl Component for ListHea...
fim
yewstack/yew
rust
<|fim_prefix|>use yew::prelude::*; use crate::Hovered; #[derive(PartialEq, Clone, Properties)] pub struct Props { #[prop_or_default] pub hide: bool, pub on_hover: Callback<Hovered>, pub name: AttrValue, #[prop_or_default] pub children: Children, } pub struct ListItem; impl Component for List...
fim
yewstack/yew
rust
<|fim_suffix|>nk<List>, } pub struct List { inactive: bool, } impl Component for List { type Message = Msg; type Properties = Props; fn create(ctx: &Context<Self>) -> Self { ctx.props() .weak_link .borrow_mut() .replace(ctx.link().clone()); Self { i...
fim
yewstack/yew
rust
<|fim_prefix|>mod app; mod header; mod item; mod list; use std::cell::RefCell; use std::fmt; use std::ops::Deref; use std::rc::Rc; use yew::html::{ImplicitClone, IntoPropValue, Scope}; use yew::prelude::*; pub struct WeakComponentLink<COMP: Component>(Rc<RefCell<Option<Scope<COMP>>>>); impl<COMP: Component> Clone f...
fim
yewstack/yew
rust
<|fim_suffix|>ouseover={ctx.link().callback(|_| Msg::Hover)} /> } } } <|fim_prefix|>use yew::prelude::*; pub enum Msg { Hover, } #[derive(Properties, PartialEq)] pub struct Props { pub on_hover: Callback<<|fim_middle|>()>, pub placeholder: AttrValue, pub input_ref: NodeRef, } ...
fim
yewstack/yew
rust
<|fim_suffix|> <h1>{"Create your account"}</h1> <div class="input-container"> <label>{ "Email" }</label> <input type="text" ref={&self.refs[0]} ...
fim
yewstack/yew
rust
<|fim_suffix|>e(_ctx: &Context<Self>) -> Self { Self::default() } fn update(&mut self, _ctx: &Context<Self>, msg: Self::Message) -> bool { match msg { Msg::SetPassword(next_password) => self.password = next_password, Msg::RegeneratePassword => self.password = generate_pa...
fim
yewstack/yew
rust
<|fim_prefix|>#![recursion_limit = "256"] mod text_input; mod app; mod password; use app<|fim_suffix|>ew::Renderer::<App>::new().render(); } <|fim_middle|>::App; fn main() { y<|endoftext|>
fim
yewstack/yew
rust
<|fim_suffix|> f64).floor() as usize; result.push(space[i]); } result } <|fim_prefix|>const PASSWORD_LEN: i32 = 17; pub fn generate_password() -> String { let mut space: Vec<char> = vec![]; for c in 'a'..='z' { space.push(c); } for c in 'A'..='Z' { space.push(c); } ...
fim
yewstack/yew
rust
<|fim_prefix|>use wasm_bindgen::{JsCast, UnwrapThrowExt}; use web_sys::{Event, HtmlInputEleme<|fim_suffix|> HtmlInputElement = event_target.dyn_into().unwrap_throw(); web_sys::console::log_1(&target.value().into()); target.value() } /// Controlled Text Input Component #[function_component(TextInput)] pub fn te...
fim
yewstack/yew
rust
<|fim_prefix|>use wasm_bindgen::JsCast; use web_sys::{Element, ShadowRootInit, ShadowRootMode}; use yew::{Component, Context, Html, NodeRef, Properties, create_portal, html}; #[derive(Properties, PartialEq)] pub struct ShadowDOMProps { #[prop_or_default] pub children: Html, } pub struct ShadowDOMHost { ho...
fim
yewstack/yew
rust
use yew::prelude::*; use yew_router::prelude::*; use crate::Route; use crate::content::Author; use crate::generator::Generated; #[derive(Clone, Debug, PartialEq, Eq, Properties)] pub struct Props { pub seed: u64, } pub struct AuthorCard { author: Author, } impl Component for AuthorCard { type Message = (...
fim
yewstack/yew
rust
<|fim_prefix|>pub mod author_<|fim_suffix|> mod pagination; pub mod post_card; pub mod progress_delay; <|fim_middle|>card; pub<|endoftext|>
fim
yewstack/yew
rust
<|fim_suffix|>terator, { if len > max_links { let last_link = self.render_link(pages.next_back().unwrap(), props); // remove 1 for the ellipsis and 1 for the last link html! { for page in pages.take(max_links - 2) { { self.render_link(p...
fim
yewstack/yew
rust
<|fim_prefix|>use yew::prelude::*; use yew_router::components::Link; use crate::Route; use crate::content::PostMeta; use crate::generator::Generated; #[derive(Clone, Debug, PartialEq, Eq, Properties)] pub struct Props { pub seed: u64, } pub struct PostCard { post: PostMeta, } impl Component for PostCard<|fim...
fim
yewstack/yew
rust
<|fim_suffix|> if elapsed > duration { ctx.props().on_complete.emit(()); self.start = Instant::now(); } else { ctx.props().on_progress.emit(self.value); } true } } } ...
fim
yewstack/yew
rust
<|fim_suffix|>t the seed. // This doesn't matter here though, because we don't need it. if r#gen.chance(1, 10) { Self::Quote(Quote::generate(r#gen)) } else { Self::Section(Section::generate(r#gen)) } } } #[derive(Clone, Debug, Eq, PartialEq)] pub struct Secti...
fim
yewstack/yew
rust
<|fim_suffix|> Self::generate(&mut Generator::from_seed(seed)) } } <|fim_prefix|>use std::sync::LazyLock; use lipsum::MarkovChain; use rand_09::distr::Bernoulli; use rand_09::rngs::SmallRng; use rand_09::seq::IteratorRandom; use rand_09::{Rng, SeedableRng}; const KEYWORDS: &str = include_str!("../data/keywor...
fim
yewstack/yew
rust
<|fim_suffix|> { "More" } </div> <div class="navbar-dropdown"> <Link<Route> classes={classes!("navbar-item")} to={Route::Authors}> { "Meet the authors" } ...
fim
yewstack/yew
rust
<|fim_suffix|>pan class="tag is-info">{ tag }</span> } </div> </article> </div> <div class="tile is-parent"> <figure class="tile is-child image is-s...
fim
yewstack/yew
rust
<|fim_suffix|>orCard {seed} /> </div> </div> } </div> <ProgressDelay duration_ms={CAROUSEL_DELAY_MS} on_complete={ctx.link().callback(|_| Msg::NextAuthors)} /> </div> <...
fim
yewstack/yew
rust
<|fim_prefix|>use yew::prelude::*; pub struct Home; impl Component for Home { type Message = (); type Properties = (); fn create(_ctx: &Context<Self>) -> Self { Self } fn view(&self, _ctx: &Context<Self>) -> Html { html! { <div class="tile is-ancestor is-vertical"> ...
fim
yewstack/yew
rust
pub mod author; pub mod author_list; pub mod home; pub mod page_not_found; pub mod post; pub mod post_list; <|endoftext|>
fim
yewstack/yew
rust
<|fim_suffix|> <h2 class="subtitle"> { "Page page does not seem to exist" } </h2> </div> </div> </section> } } } <|fim_prefix|>use yew::prelude::*; pub struct PageNotFound; impl Componen...
fim
yewstack/yew
rust
<|fim_prefix|>use content::PostPart; use yew::prelude::*; use yew_router::prelude::*; use crate::generator::Generated; use crate::{Route, content}; #[derive(Clone, Debug, Eq, PartialEq, Properties)] pub struct Props { pub seed: u64, } pub struct Post { post: content::Post, } impl Component for Post { typ...
fim
yewstack/yew
rust
<|fim_suffix|> page: current_page(ctx), _listener: listener, } } fn update(&mut self, ctx: &Context<Self>, msg: Self::Message) -> bool { match msg { Msg::PageUpdated => self.page = current_page(ctx), } true } fn view(&self, _ctx: &Context<Self>...
fim
yewstack/yew
rust
<|fim_prefix|>use simple_ssr::App; fn main() { #[cfg(target_arch = "wasm32")] { let fmt_layer = tracing_subscriber::fmt::layer() .with_ansi(false) // Only partially supported across browsers .without_time() // std::time is not available in browsers <|fim_suffix|>racing_subscr...
fim
yewstack/yew
rust
<|fim_prefix|>use std::convert::Infallible; use s<|fim_suffix|>ove { let body = render(index_html_before, index_html_after).await; warp::reply::with_header( warp::reply::stream(body), "content-type", "text/html; charset=utf-8", ) ...
fim
yewstack/yew
rust
<|fim_suffix|> .build() .unwrap(); let resp = client .get("https://httpbingo.org/uuid") .send() .await .unwrap() .error_for_status() .unwrap(); let uuid_resp = resp.json::<UuidResponse>().await.unwrap(); uuid_resp.uuid } #[function_component]...
fim
yewstack/yew
rust
<|fim_prefix|>#![cfg(all(target_arch = "wasm32", not(target_os = "wasi")))] use simple_ssr::App; use ssr_e2e_harness::{output_element, setup_ssr_page, wait_for}; use wasm_bindgen_test::*; wasm_bindgen_test_configure!(run_in_browser); const SERVER_BASE: &str = "http://127.0.0.1:8080"; #[wasm_bindgen_test] async fn h...
fim
yewstack/yew
rust
<|fim_suffix|> <div class="content"> <h2>{" Yew Suspense Demo -- function component consumer"}</h2> <Suspense fallback={fallback_fn}> <AppContent /> </Suspense> </div> <div class="content"> <h...
fim
yewstack/yew
rust
use web_sys::HtmlTextAreaElement; use yew::prelude::*; use crate::use_sleep; #[function_component] pub fn WithSleep<Comp>() -> HtmlResult where Comp: BaseComponent<Properties = AppContentProps>, { let sleep = use_sleep()?; let sleep = Callback::from(move |_| sleep()); Ok(yew::virtual_dom::VChild::<Com...
fim
yewstack/yew
rust
<|fim_prefix|>use std::rc::Rc; use std::time::Duration; use gloo::timers::future::sleep; use yew::prelude::*; use yew::suspense::{Suspension, SuspensionResult}; #[derive(PartialEq)] pub struct SleepState { s: Suspension, } impl SleepState { fn new() -> Self { let s = Suspension::from_fu<|fim_suffix|>...
fim
yewstack/yew
rust
<|fim_suffix|>er() { <p>{ message }</p> } </div> </div> } } } impl App { fn log(&mut self, message: impl Into<AttrValue>) { self.messages.push(message.into()); } } fn main() { yew::Renderer::<App>::new().render(); ...
fim
yewstack/yew
rust
<|fim_suffix|> let has_job = state.interval_handle.is_some() || state.timeout_handle.is_some(); let on_add_timeout = { let state = state.clone(); Callback::from(move |_: MouseEvent| { let timeout_state = state.clone(); let message_state = state.clone(); let...
fim
yewstack/yew
rust
<|fim_prefix|>use gloo::storage::{LocalStorage, Storage}; use state::{Entry, Filter, State}; use strum::IntoEnumIterator; use web_sys::HtmlInputElement as InputElement; use yew::events::{FocusEvent, KeyboardEvent}; use yew::{Classes, Component, Context, Html, NodeRef, TargetCast, classes, html}; mod state; const KEY:...
fim
yewstack/yew
rust
use serde_derive::{Deserialize, Serialize}; use strum_macros::{Display, EnumIter}; use yew::html::IntoPropValue; use yew::prelude::*; #[derive(Debug, Serialize, Deserialize)] pub struct State { pub entries: Vec<Entry>, pub filter: Filter, pub edit_value: String, } impl State { pub fn new(entries: Vec<...
fim
yewstack/yew
rust
<|fim_suffix|>Two".into()))}>{ "Two" }</button> <button onclick={ctx.link().callback(|_| Msg::SendToOpposite("Three".into()))}>{ "Three" }</button> <button onclick={ctx.link().callback(|_| Msg::SendToOpposite("Ping".into()))}>{ "Ping" }</button> </div> } } } fn m...
fim
yewstack/yew
rust
<|fim_suffix|>()); history.push("/"); html! { <div> <Router history={history}> <Content /> </Router> </div> } } pub async fn render() -> Result<String> { let renderer = LocalServerRenderer::<App>::new(); let html_raw = renderer.render().await...
fim
yewstack/yew
rust
<|fim_prefix|>use yew::prelude::*; use yew_router::prelude::*; #[derive(Routable, PartialEq, Eq, Clone, Debug)] pub enum Route { #[at("/")] Portal, #[at("/t/{id}")] Thread { id: String }, #[not_found] #[at("/404")] NotFound, } pub fn switch(routes: Route) -> Html { html! { <|fi...
fim
yewstack/yew
rust
<|fim_suffix|>lse { fib(n - 1) + fib(n - 2) } } fib(n) } <|fim_prefix|>use js_sys::Uint8Array; use serde::{Deserialize, Serialize}; use wasm_bindgen::JsValue; use yew_agent::Codec; use yew_agent::prelude::*; /// Example to use a custom codec. pub struct Postcard; impl Codec for Postcard { fn encode<I>(in...
fim
yewstack/yew
rust
<|fim_prefix|>fn<|fim_suffix|>p>::new().render(); } <|fim_middle|> main() { yew::Renderer::<yew_worker_fib::Ap<|endoftext|>
fim
yewstack/yew
rust
<|fim_suffix|>tcard>().register(); } <|fim_prefix|>use yew_agent::Registrable; use yew_worker_fib::agent::{FibonacciTask, Postcard}; fn main() { FibonacciTask::<|fim_middle|>registrar().encoding::<Pos<|endoftext|>
fim
yewstack/yew
rust
<|fim_prefix|>#![recursion_limit = "1024"] #![allow(clippy::large_enum_variant)] pub mod agent; use web_sys::HtmlInputElement; use yew::platform::spawn_local; use yew::prelude::*; use yew_agent::oneshot::{OneshotProvider, use_oneshot_runner}; use crate::agent::{FibonacciTask, Postcard}; #[function_component] fn Mai...
fim
yewstack/yew
rust
<|fim_suffix|> Some(m) = scope.next().await { if m == ControlSignal::Start { 'inner: for i in 1.. { // This is not the most efficient way to calculate prime, // but this example is here to demonstrate how primes can be // sent to the application in an ...
fim
yewstack/yew
rust
<|fim_suffix|>_worker_prime::App>::new().render(); } <|fim_prefix|>fn main() { yew::Renderer::<<|fim_middle|>yew<|endoftext|>
fim
yewstack/yew
rust
<|fim_suffix|>eactor; fn main() { PrimeReactor::registrar().register(); } <|fim_prefix|>use ye<|fim_middle|>w_agent::Registrable; use yew_worker_prime::agent::PrimeR<|endoftext|>
fim
yewstack/yew
rust
<|fim_suffix|>rimeReactor>> } } <|fim_prefix|>pub mod agent; use agent::{ControlSignal, PrimeReactor}; use yew::prelude::*; use yew_agent::reactor::{ReactorProvider, use_reactor_subscription}; #[function_component] fn Main() -> Html { let prime_sub = use_reactor_subscription::<PrimeReactor>(); let started ...
fim
yewstack/yew
rust
<|fim_prefix|>use std::cell::RefCell; use std::rc::Rc; use wasm_bindgen::JsCast; use wasm_bindgen::prelude::*; use web_sys::{HtmlCanvasElement, WebGlRenderingContext as GL, WebGlRenderingContext, window}; use yew::{Component, Context, Html, NodeRef, html}; // Wrap gl in Rc (Arc for multi-threaded) so it can be inject...
fim
yewstack/yew
rust
//! [AppHandle] contains the state Yew keeps to bootstrap a component in an isolated scope. use std::ops::Deref; use std::rc::Rc; use web_sys::Element; use crate::dom_bundle::{BSubtree, DomSlot}; use crate::html::{BaseComponent, Scope, Scoped}; /// An instance of an application. #[derive(Debug)] pub struct AppHandl...
fim
yewstack/yew
rust
<|fim_suffix|>hich can be called multiple times pub(crate) cb: Rc<dyn Fn(&mut IN) -> OUT>, } generate_callback_impls!(CallbackRefMut, &mut IN, output => &mut output); #[cfg(test)] mod test { use std::sync::Mutex; use super::*; /// emit the callback with the provided value fn emit<T, I, R: 'stati...
fim
yewstack/yew
rust
<|fim_prefix|>//! This module defines the `ContextProvider` component. use std::cell::RefCell; use slab::Slab; use crate::html::Scope; use crate::{Callback, Component, Context, Html, Properties}; /// Props for [`ContextProvider`] #[derive(Debug, Clone, PartialEq, Properties)] pub struct ContextProviderProps<T: Clon...
fim
yewstack/yew
rust
<|fim_prefix|>//! This module contains the bundle implementation of a virtual component [BComp]. use std::any::TypeId; use std::borrow::Borrow; use std::fmt; use web_sys::Element; use super::{BNode, BSubtree, DomSlot, DynamicDomSlot, Reconcilable, ReconcileTarget}; use crate::html::{AnyScope, Scoped}; use crate::vir...
fim
yewstack/yew
rust
<|fim_suffix|>ves as the next expected node index if the order has not changed, and of the // position of `` let mut barrier_idx = middle_count; struct RunInformation<'a> { start_writer: NodeWriter<'a>, // Index in `replacements` where this run started start_i...
fim
yewstack/yew
rust
<|fim_prefix|>//! This module contains the bundle version of an abstract node [BNode] use std::fmt; use web_sys::{Element, Node}; use super::{BComp, BList, BPortal, BRaw, BSubtree, BSuspense, BTag, BText, DomSlot}; use crate::dom_bundle::{Reconcilable, ReconcileTarget}; use crate::html::AnyScope; use crate::utils::R...
fim
yewstack/yew
rust
<|fim_prefix|>//! This module contains the bundle implementation of <|fim_suffix|>let new_input_el = input_ref.cast::<HtmlInputElement>().unwrap(); assert_eq!(input_el, new_input_el); assert_eq!(document().active_element(), Some(new_input_el.into())); } } <|fim_middle|>a portal [BPortal]. use web_s...
fim
yewstack/yew
rust
<|fim_prefix|>use wasm_bindgen::JsCast; use web_sys::{Element, Node}; use super::{BNode, BSubtree, DomSlot, Reconcilable, ReconcileTarget}; use crate::AttrValue; use crate::html::AnyScope; use crate::virtual_dom::VRaw; use crate::virtual_dom::vtag::{MATHML_NAMESPACE, SVG_NAMESPACE}; #[derive(Debug)] pub struct BRaw {...
fim
yewstack/yew
rust
<|fim_prefix|>//! This module contains the bundle version of a suspense [BSuspense] use gloo::utils::document; use web_sys::Element; #[cfg(feature = "hydration")] use super::Fragment; use super::{BNode, BSubtree, DomSlot, Reconcilable, ReconcileTarget}; use crate::html::AnyScope; use crate::virtual_dom::{Key, VSuspen...
fim
yewstack/yew
rust
<|fim_prefix|>use std::collections::HashMap; use std::ops::Deref; use indexmap::IndexMap; use wasm_bindgen::{JsValue, intern}; use web_sys::{Element, HtmlInputElement as InputElement, HtmlTextAreaElement as TextAreaElement}; use yew::AttrValue; use super::Apply; use crate::dom_bundle::BSubtree; use crate::virtual_dom...
fim
yewstack/yew
rust
<|fim_prefix|>use std::cell::RefCell; use std::collections::HashMap; use std::ops::Deref; use std::rc::Rc; use wasm_bindgen::JsCast; use wasm_bindgen::prelude::wasm_bindgen; use web_sys::{Element, Event, EventTarget as HtmlEventTarget}; use super::Apply; use crate::dom_bundle::{BSubtree, EventDescriptor, test_log}; u...
fim
yewstack/yew
rust
//! This module contains the bundle implementation of a tag [BTag] mod attributes; mod listeners; use std::cell::RefCell; use std::collections::HashMap; use std::hint::unreachable_unchecked; use std::ops::DerefMut; use gloo::utils::document; use listeners::ListenerRegistration; pub use listeners::Registry; use wasm_...
fim
yewstack/yew
rust
<|fim_prefix|>//! This module contains the bundle implementation of text [BText]. use gloo::utils::document; use web_sys::{Element, Text as TextNode}; use super::{BNode, BSubtree, DomSlot, Reconcilable, ReconcileTarget}; use crate::html::AnyScope; use crate::virtual_dom::{AttrValue, VText}; /// The bundle implementa...
fim
yewstack/yew
rust
<|fim_suffix|>e collecting, breaking // the loop. // We remove the closing tag. parent.remove_child(&current_node).unwrap(); break; } } } nodes.push_back(current_...
fim
yewstack/yew
rust
<|fim_suffix|> pub(super) use super::utils::node_type_str; #[path = "./fragment.rs"] mod fragment; pub(crate) use fragment::Fragment; use super::*; impl Bundle { /// Creates a bundle by hydrating a virtual dom layout. pub fn hydrate( root: &BSubtree, pare...
fim
yewstack/yew
rust
<|fim_suffix|> replacement = DomSlot::at(document().create_element("p").unwrap().into()); target.reassign(replacement.clone()); assert_eq!( target_pos.get(), replacement.get(), "expected {target:#?} to point to the same position as {replacement:#?}" ); } ...
fim
yewstack/yew
rust
<|fim_suffix|>ntTarget) -> Self { Self::do_create_root(host_element, None) } /// Create a bundle root at the specified host element, that is logically /// mounted under the specified element in this tree. pub fn create_subroot(&self, mount_point: Element, host_element: &HtmlEventTarget) -> Self...
fim
yewstack/yew
rust
<|fim_prefix|>use web_sys::Element; use super::{BNode, BSubtree, DomSlot}; use crate::html::AnyScope; /// A Reconcile Target. /// /// When a [Reconcilable] is attached, a reconcile target is created to store additional /// information. pub(super) trait ReconcileTarget { /// Rem<|fim_suffix|>coped diff apply to ot...
fim
yewstack/yew
rust
<|fim_suffix|> document().body().unwrap().append_child(&parent).unwrap(); let end = document().create_text_node(SIBLING_CONTENT); parent.append_child(&end).unwrap(); let sibling = DomSlot::at(end.into()); (root, scope, parent, sibling) } } <|fim_prefix|>#[cfg(all(test, targ...
fim
yewstack/yew
rust
mod use_callback; mod use_context; mod use_effect; mod use_force_update; mod use_memo; mod use_prepared_state; mod use_reducer; mod use_ref; mod use_state; mod use_transitive_state; pub use use_callback::*; pub use use_context::*; pub use use_effect::*; pub use use_force_update::*; pub use use_memo::*; pub use use_pr...
fim
yewstack/yew
rust
<|fim_prefix|>use std::rc::Rc; use crate::callback::Callback; use crate::functional::{hook, use_memo}; /// Get a immutable reference to a memoized `Callback`. Its state persists across renders. /// It will be recreated only if any of the dependencies changes value. /// /// Memoization means it will only get recreated...
fim
yewstack/yew
rust
<|fim_prefix|>use std::cell::RefCell; use std::marker::PhantomData; use std::rc::Rc; use crate::callback::Callback; use crate::context::ContextHandle; use crate::functional::{Hook, HookContext}; /// Hook for consuming context values in function components. /// The context of the type passed as `T` is returned. If the...
fim
yewstack/yew
rust
<|fim_suffix|>nly-on-first-render) but put the code in the cleanup function. /// It will only get called when the component is removed from view / gets destroyed. /// /// ```rust /// use yew::{Html, component, html, use_effect_with}; /// # use gloo::console::log; /// /// #[component] /// fn HelloWorld() -> Html { /// ...
fim
yewstack/yew
rust
<|fim_prefix|>use std::fmt; use super::{Hook, HookContext}; use crate::functional::ReRender; /// A handle which can be used to force a re-render of the associated /// function component. #[derive(Clone)] pub struct UseForceUpdateHandle { trigger: ReRender, } impl fmt::Debug for UseForceUpdateHandle { fn fmt(...
fim
yewstack/yew
rust
<|fim_suffix|>/ /// html! { /// <div> /// <span>{ (*message).clone() }</span> /// </div> /// } /// } /// ``` #[hook] pub fn use_memo<T, F, D>(deps: D, f: F) -> Rc<T> where T: 'static, F: FnOnce(&D) -> T, D: 'static + PartialEq, { use_memo_base(|d| (f(&d), d), deps) } ...
fim
yewstack/yew
rust
<|fim_prefix|>//! The client-side rendering variant. This is used for client side rendering. use std::marker::PhantomData; use std::rc::Rc; use serde::Serialize; use serde::de::DeserializeOwned; use wasm_bindgen::JsValue; use super::PreparedStateBase; use crate::functional::{Hook, HookContext, use_state}; use crate:...
fim
yewstack/yew
rust
<|fim_suffix|>U> where D: Serialize + DeserializeOwned + PartialEq + 'static, T: Serialize + DeserializeOwned + 'static, F: FnOnce(Rc<D>) -> U, U: 'static + Future<Output = T>, { deps: D, f: F, } impl<T, D, F, U> Hook for HookProvider<T, D, F, U> wher...
fim
yewstack/yew
rust
<|fim_prefix|>//! The noop variant. This is used for client side rendering when hydration is disabled. use std::rc::Rc; use serde::Serialize; use serde::de::DeserializeOwned; use crate::hook; use crate::suspense::SuspensionResult; #[doc(hidden)] #[hook] pub fn use_prepared_state<T, D>(_deps: D) -> SuspensionResult<...
fim
yewstack/yew
rust
<|fim_prefix|>//! The server-side rendering variant. This is used for server side rendering. use std::marker::PhantomData; use std::rc::Rc; use serde::Serialize; use serde::de::DeserializeOwned; use super::PreparedStateBase; use crate::functional::{Hook, HookContext, use_memo, use_state}; use crate::platform::spawn_...
fim
yewstack/yew
rust
<|fim_suffix|>uct PreparedStateBase<T, D> where D: Serialize + DeserializeOwned + PartialEq + 'static, T: Serialize + DeserializeOwned + 'static, { #[cfg(feature = "ssr")] pub state: Option<Rc<T>>, #[cfg(feature = "ssr")] pub deps: Option<Rc<D>>, #[cfg(fea...
fim
yewstack/yew
rust
<|fim_prefix|>use std::cell::RefCell; use std::fmt; use std::marker::PhantomData; use std::ops::Deref; use std::rc::Rc; use implicit_clone::ImplicitClone; use crate::Callback; use crate::functional::{Hook, HookContext, hook}; use crate::html::IntoPropValue; type DispatchFn<T> = Rc<dyn Fn(<T as Reducible>::Action)>; ...
fim
yewstack/yew
rust