text stringlengths 14 100k | source stringclasses 1
value | repo stringclasses 810
values | language stringclasses 13
values |
|---|---|---|---|
<|fim_prefix|>use std::cell::RefCell;
use std::rc::Rc;
use crate::NodeRef;
use crate::functional::{Hook, HookContext, hook, use_state};
struct UseRef<F> {
init_fn: F,
}
impl<T: 'static, F: FnOnce() -> T> Hook for UseRef<F> {
type Output = Rc<T>;
fn run(self, ctx: &mut HookContext) -> Self::Output {
... | fim | yewstack/yew | rust |
<|fim_suffix|>
pub struct UseStateSetter<T> {
inner: UseReducerDispatcher<UseStateReducer<T>>,
}
impl<T> Clone for UseStateSetter<T> {
fn clone(&self) -> Self {
Self {
inner: self.inner.clone(),
}
}
}
impl<T> fmt::Debug for UseStateSetter<T>
where
T: fmt::Debug,
{
fn fm... | fim | yewstack/yew | rust |
<|fim_suffix|>_hydration::use_prepared_state as use_transitive_state;
<|fim_prefix|>//! The hydration vari<|fim_middle|>ant.
//!
//! This is the same as the use_prepared_state.
#[doc(hidden)]
pub use crate::functional::hooks::use_prepared_state::feat<|endoftext|> | fim | yewstack/yew | rust |
<|fim_suffix|>zeOwned + 'static,
F: 'static + FnOnce(Rc<D>) -> T,
{
deps: D,
f: F,
}
impl<T, D, F> Hook for HookProvider<T, D, F>
where
D: Serialize + DeserializeOwned + PartialEq + 'static,
T: Serialize + DeserializeOwned + 'static,
F: 'static + FnOnce(R... | fim | yewstack/yew | rust |
<|fim_prefix|>//! The noop variant. This is used for client side rendering when hydratio<|fim_suffix|>pared_state as use_transitive_state;
<|fim_middle|>n is disabled.
#[doc(hidden)]
pub use crate::functional::hooks::use_prepared_state::feat_none::use_pre<|endoftext|> | fim | yewstack/yew | rust |
<|fim_prefix|>//! The server-side rendering variant.
use std::cell::RefCell;
use std::rc::Rc;
use base64ct::{Base64, Encoding};
use serde::Serialize;
use serde::de::DeserializeOwned;
use crate::functional::{Hook, HookContext, PreparedState};
use crate::suspense::SuspensionResult;
pub(super) struct TransitiveStateBa... | fim | yewstack/yew | rust |
<|fim_prefix|>#[cfg(feature = "hydration")]
mod feat_hydration;
#[cfg(all(feature = "ssr", feature = "hydration"))]
mod feat_hydration_ssr;
#[cfg(not(any(feature = "hydration", feature = "ssr")))]
mod feat_none;
#[cfg(feature = "ssr")]
mod feat_ssr;
#[cfg(all(feature = "hydration", not(feature = "ssr")))]
pub use feat... | fim | yewstack/yew | rust |
<|fim_prefix|>//! Function components are a simplified version of normal components.
//! They consist of a single function annotated with the attribute `#[component]`
//! that receives props and determines what should be rendered by returning [`Html`](crate::Html).
//!
//! Functions with the attribute have to return `H... | fim | yewstack/yew | rust |
<|fim_suffix|> true => Self::new(),
false => Self {
set: Rc::new(IndexSet::from_iter([t])),
},
},
true => Self::from(&t),
}
}
}
impl<T: Into<Classes>> From<Option<T>> for Classes {
fn from(t: Option<T>) -> Self {
t... | fim | yewstack/yew | rust |
<|fim_prefix|>//! Component children module
use std::fmt;
use std::rc::Rc;
use crate::html::{Html, ImplicitClone};
use crate::utils::RcExt;
use crate::virtual_dom::{VChild, VComp, VList, VNode};
use crate::{BaseComponent, Properties};
/// A type used for accepting children elements in Component::Properties.
///
/// ... | fim | yewstack/yew | rust |
<|fim_suffix|>ered" callback, hence we
// want to prioritize this.
scheduler::push_component_priority_render(
self.comp_id,
Box::new(RenderRunner {
state: shared_state.clone(),
}),
);
... | fim | yewstack/yew | rust |
<|fim_suffix|>//
/// // This provider does not exist on the server-side
/// // Hydration will fail due to Virtual DOM layout mismatch.
/// <Provider4>
/// <Comp />
/// </Provider4>
///
/// </Provider3... | fim | yewstack/yew | rust |
<|fim_prefix|>//! Components wrapped with context including properties, state, and link
mod children;
#[cfg(any(feature = "csr", feature = "ssr"))]
mod lifecycle;
mod marker;
mod properties;
mod scope;
use std::rc::Rc;
pub use children::*;
#[cfg(feature = "csr")]
pub(crate) use lifecycle::PendingRendered;
pub use ma... | fim | yewstack/yew | rust |
//! Component properties module
pub use yew_macro::Properties;
/// Trait for building properties for a component
pub trait Properties: PartialEq {
/// Builder that will be used to construct properties
type Builder;
/// Entrypoint for building properties
fn builder() -> Self::Builder;
}
#[doc(hidden)... | fim | yewstack/yew | rust |
<|fim_prefix|>//! Component scope module
use std::any::{Any, TypeId};
use std::marker::PhantomData;
use std::ops::Deref;
use std::rc::Rc;
use std::{fmt, iter};
use futures::{Stream, StreamExt};
use super::BaseComponent;
#[cfg(any(feature = "csr", feature = "ssr"))]
use super::lifecycle::ComponentState;
use crate::ca... | fim | yewstack/yew | rust |
<|fim_prefix|>use std::borrow::Cow;
use std::rc::Rc;
use std::sync::Arc;
pub use implicit_clone::ImplicitClone;
use implicit_clone::unsync::{IArray, IMap};
use crate::callback::Callback;
use crate::html::{BaseComponent, ChildrenRenderer, Component, Scope};
use crate::virtual_dom::{AttrValue, VChild, VList, VNode, VTe... | fim | yewstack/yew | rust |
<|fim_prefix|>mod<|fim_suffix|>alue::*;
<|fim_middle|> into_prop_value;
pub use into_prop_v<|endoftext|> | fim | yewstack/yew | rust |
<|fim_prefix|>use thiserror::Error;
use crate::suspense::Suspension;
/// Render Error.
#[derive(Error, Debug<|fim_suffix|>Result.
pub type RenderResult<T> = std::result::Result<T, RenderError>;
<|fim_middle|>, Clone, PartialEq)]
pub enum RenderError {
/// Component Rendering Suspended
#[error("component rende... | fim | yewstack/yew | rust |
<|fim_prefix|>// Inspired by: http://package.elm-lang.org/packages/elm-lang/html/2.0.0/Html-Events
macro_rules! impl_action {
($($action:ident($type:ident) -> $ret:path => $convert:path)*) => {$(
impl_action!($action($type, false) -> $ret => $convert);
)*};
($($action:ident($type:ident, $passive:li... | fim | yewstack/yew | rust |
<|fim_suffix|> child
/// consider using [`TargetCast::target_unchecked_into<T>`]_
#[inline]
fn target_dyn_into<T>(&self) -> Option<T>
where
T: AsRef<EventTarget> + JsCast,
{
self.as_ref()
.target()
.and_then(|target| target.dyn_into().ok())
}
#[inline... | fim | yewstack/yew | rust |
<|fim_prefix|>//! The main html module which defines components, listeners, and class helpers.
mod classes;
mod component;
mod conversion;
mod error;
mod listener;
use std::cell::RefCell;
use std::rc::Rc;
pub use classes::*;
pub use component::*;
pub use conversion::*;
pub use error::*;
pub use listener::*;
use wasm... | fim | yewstack/yew | rust |
<|fim_suffix|>nts/properties
pub use yew_macro::props;
/// This module contains macros which implements html! macro and JSX-like templates
pub mod macros {
pub use crate::{classes, html, html_nested, props};
}
pub mod callback;
pub mod context;
#[cfg(feature = "csr")]
mod dom_bundle;
pub mod functional;
pub mod h... | fim | yewstack/yew | rust |
<|fim_suffix|>me is implemented with different runtimes depending on the target platform and can
//! use all features (timers / IO / task synchronisation) from the selected native runtime:
//!
//! - `wasm-bindgen-futures` (WebAssembly targets)
//! - `tokio` (non-WebAssembly targets)
#[doc(inline)]
pub use tokise::*;
<... | fim | yewstack/yew | rust |
<|fim_prefix|>use std::cell::Cell;
use std::panic::PanicHookInfo;
use std::rc::Rc;
use web_sys::Element;
use crate::app_handle::AppHandle;
use crate::html::BaseComponent;
thread_local! {
static PANIC_HOOK_IS_SET: Cell<bool> = const { Cell::new(false) };
}
/// Set a custom panic hook.
/// Unless a panic hook is ... | fim | yewstack/yew | rust |
//! This module contains a scheduler.
use std::cell::RefCell;
use std::collections::BTreeMap;
use std::rc::Rc;
#[cfg(any(test, feature = "test"))]
mod flush_wakers {
use std::cell::RefCell;
use std::task::Waker;
thread_local! {
static FLUSH_WAKERS: RefCell<Vec<Waker>> = const { RefCell::new(Vec::n... | fim | yewstack/yew | rust |
<|fim_prefix|>/// Base traits <|fim_suffix|>it Sealed {}
<|fim_middle|>for sealed traits.
pub tra<|endoftext|> | fim | yewstack/yew | rust |
<|fim_prefix|>use std::fmt;
use futures::pin_mut;
use futures::stream::{Stream, StreamExt};
use tracing::Instrument;
use crate::html::{BaseComponent,<|fim_suffix|>rties.
///
/// # Note
///
/// The properties does not have to implement `Send`.
/// However, the function to create properties needs to... | fim | yewstack/yew | rust |
<|fim_prefix|>use crate::html::{Html, Properties};
/// Properties for [Suspense].
#[derive(Properties, PartialEq, Debug, Clone)]
pub struct SuspenseProps {
/// The Children of the current Suspense Component.
#[prop_or_default]
pub children: Html,
/// The Fallback UI of the current Suspense Component.
... | fim | yewstack/yew | rust |
<|fim_suffix|>::Poll::Ready
///
/// # Example
///
/// ```
/// # use yew::prelude::*;
/// # use yew::suspense::use_future;
/// use gloo::net::http::Request;
///
/// const URL: &str = "https://en.wikipedia.org/w/api.php?\
/// action=query&origin=*&format=json&generator=search&\
/// g... | fim | yewstack/yew | rust |
<|fim_suffix|>;
pub use hooks::*;
pub use suspension::{Suspension, SuspensionHandle, SuspensionResult};
<|fim_prefix|>//! This module provides suspense support.
mod component;
mod ho<|fim_middle|>oks;
mod suspension;
#[cfg(any(feature = "csr", feature = "ssr"))]
pub(crate) use component::BaseSuspense;
pub use compone... | fim | yewstack/yew | rust |
<|fim_prefix|>use std::cell::RefCell;
use std::pin::Pin;
use std::rc::Rc;
use std::sync::atomic::{AtomicBool, Ordering};
use std::task::{Context, Poll};
use thiserror::Error;
use crate::Callback;
use crate::platform::spawn_local;
thread_local! {
static SUSPENSION_ID: RefCell<usize> = const { RefCell::new(0) };
}... | fim | yewstack/yew | rust |
<|fim_prefix|>//! Snapshot testing of Yew components
//!
//! This tests must be run in browser and thus require the `csr` feature to be enabled
use gloo::console::log;
use crate::dom_bundle::{BSubtree, Bundle, DomSlot};
use crate::html::AnyScope;
use crate::virtual_dom::VNode;
use crate::{Component, Context, Html, sch... | fim | yewstack/yew | rust |
<|fim_prefix|>//! Inter<|fim_suffix|>odule for unit tests
pub mod layout_tests;
<|fim_middle|>nal m<|endoftext|> | fim | yewstack/yew | rust |
<|fim_suffix|>rap(this).unwrap_or_else(|rc| (*rc).clone())
}
}
<|fim_prefix|>//! This module contains useful utilities to get information about the current document.
use std::marker::PhantomData;
use std::rc::Rc;
use implicit_clone::ImplicitClone;
use implicit_clone::unsync::IArray;
use yew::html::ChildrenRendere... | fim | yewstack/yew | rust |
<|fim_prefix|>//! This module contains the implementation yew's virtual nodes' keys.
use std::fmt::{self, Display, Formatter};
use std::ops::Deref;
use std::rc::Rc;
use crate::html::ImplicitClone;
/// Represents the (optional) key of Yew's virtual nodes.
///
/// Keys are cheap to clone.
#[derive(Clone, ImplicitClone... | fim | yewstack/yew | rust |
<|fim_suffix|>is should only lead in the
// worst-case to some unneeded re-renders.
Rc::ptr_eq(lhs, rhs)
}
(None, None) => true,
_ => false,
})
... | fim | yewstack/yew | rust |
<|fim_prefix|>//! This module contains Yew's implementation of a reactive virtual DOM.
#[doc(hidden)]
pub mod key;
#[doc(hidden)]
pub mod listeners;
#[doc(hidden)]
pub mod vcomp;
#[doc(hidden)]
pub mod vlist;
#[doc(hidden)]
pub mod vnode;
#[doc(hidden)]
pub mod vportal;
#[doc(hidden)]
pub mod vraw;
#[doc(hidden)]
pub ... | fim | yewstack/yew | rust |
<|fim_prefix|>//! This module contains the implementation of a virtual component (`VComp`).
use std::any::{Any, TypeId};
use std::fmt;
use std::rc::Rc;
#[cfg(feature = "ssr")]
use futures::future::{FutureExt, LocalBoxFuture};
#[cfg(feature = "csr")]
use web_sys::Element;
use super::Key;
#[cfg(feature = "hydration")]... | fim | yewstack/yew | rust |
<|fim_suffix|>rverRenderer::<Comp>::new()
.hydratable(false)
.render()
.await;
assert_eq!(s, "<div>Hello world!</div>");
}
#[cfg_attr(not(target_os = "wasi"), test)]
#[cfg_attr(target_os = "wasi", test(flavor = "current_thread"))]
async fn test_fragment() {
... | fim | yewstack/yew | rust |
<|fim_suffix|> .await
}
// We are pretty safe here as it's not possible to get a web_sys::Node without
// DOM support in the first place.
//
// The only exception would be to use `ServerRenderer` in a browser or wa... | fim | yewstack/yew | rust |
<|fim_suffix|> }
}
}
<|fim_prefix|>//! This module contains the implementation of a portal `VPortal`.
use web_sys::{Element, Node};
use super::VNode;
#[derive(Debug, Clone, PartialEq)]
pub struct VPortal {
/// The element under which the content is inserted.
pub host: Element,
/// The next sibling ... | fim | yewstack/yew | rust |
<|fim_suffix|>sr {
use std::fmt::Write;
use super::*;
use crate::html::AnyScope;
use crate::platform::fmt::BufWriter;
use crate::virtual_dom::Collectable;
impl VRaw {
pub(crate) async fn render_into_stream(
&self,
w: &mut BufWriter,
_parent_scope: &A... | fim | yewstack/yew | rust |
<|fim_suffix|>parent_vtag_kind: VTagKind,
) {
let collectable = Collectable::Suspense;
if hydratable {
collectable.write_open_tag(w);
}
// always render children on the server side.
self.children
.render_into_stream(w,... | fim | yewstack/yew | rust |
<|fim_prefix|>//! This module contains the implementation of a virtual element node [VTag].
use std::marker::PhantomData;
use std::mem;
use std::ops::{Deref, DerefMut};
use std::rc::Rc;
use wasm_bindgen::JsValue;
use web_sys::{HtmlInputElement as InputElement, HtmlTextAreaElement as TextAreaElement};
use super::{Att... | fim | yewstack/yew | rust |
<|fim_prefix|>//! This module contains the implementation of a virtual text node `VText`.
use super::AttrValue;
use crate::html::ImplicitClone;
/// A type for a virtual
/// [`TextNode`](https://developer.mozilla.org/en-US/docs/Web/API/Document/createTextNode)
/// representation.
#[derive(Clone, Impli<|fim_suffix|>_sc... | fim | yewstack/yew | rust |
<|fim_suffix|>xpect("No result found. Most likely, the application crashed and burned")
.inner_html()
}
pub fn output_element() -> web_sys::Element {
gloo::utils::document().get_element_by_id("output").unwrap()
}
<|fim_prefix|>#![allow(dead_code)]
pub fn obtain_result() -> String {
gloo::utils::docume... | fim | yewstack/yew | rust |
<|fim_prefix|>#![cfg(all(target_arch = "wasm32", not(target_os = "wasi")))]
mod common;
use common::obtain_result;
use wasm_bindgen_test::*;
use yew::prelude::*;
use yew::scheduler;
wasm_bindgen_test::wasm_bindgen_test_configure!(run_in_browser);
async fn render_and_read<C: BaseComponent<Properties = ()>>() -> Stri... | fim | yewstack/yew | rust |
<|fim_suffix|>leted}") }</div>
}
}
assert_eq!(render_and_read::<App>().await, "rows_completed=0");
}
#[wasm_bindgen_test]
async fn while_labeled_continue_no_semi() {
#[component]
fn App() -> Html {
let mut rows_skipped = 0;
'outer: for row in 0..3 {
let mut i: i32 =... | fim | yewstack/yew | rust |
<|fim_suffix|>ncrease")
.unwrap()
.unwrap()
.dyn_into::<HtmlElement>()
.unwrap()
.click();
sleep(Duration::from_millis(50)).await;
let result = obtain_result();
assert_eq!(
result.as_str(),
r#"<div class="content-area"><div class="actual-result">1</d... | fim | yewstack/yew | rust |
<|fim_suffix|> || {}
});
}
if *delayed_trigger {
html! { <div>{"failure"}</div> }
} else {
html! { <i></i><span id="result">{"success"}</span> }
}
}
#[component]
fn Top() -> Html {
html! { <Nested /> }
}
#[component]
... | fim | yewstack/yew | rust |
<|fim_prefix|>#![cfg(all(target_arch = "wasm32", not(target_os = "wasi")))]
mod common;
use common::obtain_result;
use wasm_bindgen_test::*;
use yew::prelude::*;
use yew::scheduler;
wasm_bindgen_test::wasm_bindgen_test_configure!(run_in_browser);
#[wasm_bindgen_test]
async fn props_are_passed() {
#[derive(Prope... | fim | yewstack/yew | rust |
<|fim_prefix|>mod common;
#[cfg(all(target_arch = "wasm32", not(target_os = "wasi")))]
use wasm_bindgen::JsCast;
#[cfg(all(targe<|fim_suffix|> yew::platform::time::sleep;
yew::Renderer::<App>::with_root(gloo::utils::document().get_element_by_id("output").unwrap())
.render();
// wait for render to fin... | fim | yewstack/yew | rust |
#![cfg(all(target_arch = "wasm32", not(target_os = "wasi")))]
mod common;
use std::cell::RefCell;
use std::rc::Rc;
use std::time::Duration;
use common::obtain_result;
use wasm_bindgen::JsCast;
use wasm_bindgen_test::*;
use web_sys::{HtmlElement, HtmlTextAreaElement};
use yew::platform::spawn_local;
use yew::platform... | fim | yewstack/yew | rust |
<|fim_prefix|>#![cfg(all(target_arch = "wasm32", not(target_os = "wasi")))]
use std::sync::atomic::{AtomicBool, Ordering};
mod common;
use common::obtain_result;
use wasm_bindgen_test::*;
use yew::prelude::*;
use yew::scheduler;
wasm_bindgen_test::wasm_bindgen_test_configure!(run_in_browser);
#[wasm_bindgen_test]
... | fim | yewstack/yew | rust |
<|fim_suffix|>llo world!, total: 4"
);
}
<|fim_prefix|>#![cfg(all(target_arch = "wasm32", not(target_os = "wasi")))]
mod common;
use std::rc::Rc;
use common::obtain_result_by_id;
use wasm_bindgen_test::*;
use yew::prelude::*;
use yew::scheduler;
wasm_bindgen_test::wasm_bindgen_test_configure!(run_in_browser);
... | fim | yewstack/yew | rust |
<|fim_prefix|>#![cfg(all(target_arch = "wasm32", not(target_os = "wasi")))]
mod common;
use std::ops::{Deref, DerefMut};
use std::rc::Rc;
use common::obtain_result;
use wasm_bindgen_test::*;
use yew::prelude::*;
use yew::scheduler;
wasm_bindgen_test::wasm_bindgen_test_configure!(run_in_browser);
#[wasm_bindgen_tes... | fim | yewstack/yew | rust |
<|fim_suffix|> }
|| {}
});
html! {
<div>
{"The test output is: "}
<div id="result">{*memoed_val}</div>
{"\n"}
</div>
}
}
yew::Renderer::<UseMemoComponent>::with_root(
gloo::utils::documen... | fim | yewstack/yew | rust |
<|fim_suffix|>>--><div><!--<[use_prepared_state::use_prepared_state_with_suspension_works::{{closure}}::Comp]>--><div>12345</div><script type="application/x-yew-comp-state">Afs5MAE=</script><!--</[use_prepared_state::use_prepared_state_with_suspension_works::{{closure}}::Comp]>--></div><!--</?>--><!--</[yew::suspense::... | fim | yewstack/yew | rust |
<|fim_suffix|> Change,
}
/// A state that does not implement PartialEq
#[derive(Clone)]
struct SometimesChangingState {
value: i32,
}
impl Reducible for SometimesChangingState {
type Action = SometimesChangeAction;
fn reduce(self: Rc<Self>, action: Self::Action) -> Rc<Self> {
use SometimesChang... | fim | yewstack/yew | rust |
<|fim_suffix|>et result = obtain_result();
assert_eq!(result.as_str(), "true");
}
<|fim_prefix|>#![cfg(all(target_arch = "wasm32", not(target_os = "wasi")))]
mod common;
use std::ops::DerefMut;
use common::obtain_result;
use wasm_bindgen_test::*;
use yew::prelude::*;
use yew::scheduler;
wasm_bindgen_test::wasm_... | fim | yewstack/yew | rust |
<|fim_prefix|>#![cfg(all(target_arch = "wasm32", not(target_os = "wasi")))]
mod common;
use std::rc::Rc;
use common::obtain_result;
use wasm_bindgen_test::*;
use yew::prelude::*;
use yew::scheduler;
wasm_bindgen_test::wasm_bindgen_test_configure!(run_in_browser);
#[wasm_bindgen_test]
async fn use_state_works() {
... | fim | yewstack/yew | rust |
<|fim_prefix|>#![cfg(feature = "hydration")]
#![cfg(target_arch = "wasm32")]
use std::time::Duration;
mod common;
use common::obtain_result_by_id;
use wasm_bindgen_test::*;
use yew::platform::time::sleep;
use yew::prelude::*;
use yew::{Renderer, ServerRenderer, scheduler};
wasm_bindgen_test::wasm_bindgen_test_confi... | fim | yewstack/yew | rust |
<|fim_suffix|>ub use crate::reactor::{
ReactorEvent, ReactorScope, UseReactorBridgeHandle, UseReactorSubscriptionHandle, reactor,
use_reactor_bridge, use_reactor_subscription,
};
pub use crate::scope_ext::{AgentScopeExt, ReactorBridgeHandle, WorkerBridgeHandle};
pub use crate::worker::{
... | fim | yewstack/yew | rust |
<|fim_prefix|>use yew::prelude::*;
use super::Oneshot;
use super::provider::OneshotProviderState;
/// Hook handle for [`use_oneshot_runner`]
#[derive(Debug)]
pub struct UseOneshotRunnerHandle<T>
where
T: Oneshot + 'static,
{
state: OneshotProviderState<T>,
}
impl<T> UseOneshotRunnerHandle<T>
where
T: One... | fim | yewstack/yew | rust |
<|fim_suffix|>use provider::OneshotProvider;
pub(crate) use provider::OneshotProviderState;
/// A procedural macro to create oneshot agents.
pub use yew_agent_macro::oneshot;
<|fim_prefix|>//! This module provides task agent implementation.
mod hooks<|fim_middle|>;
mod provider;
#[doc(inline)]
pub use gloo_worker::on... | fim | yewstack/yew | rust |
<|fim_suffix|>ec is can be erased from contexts.
let spawn_bridge_fn: Rc<dyn Fn() -> OneshotBridge<T>> = {
let path = path.clone();
Rc::new(move || {
OneshotSpawner::<T>::new()
.as_module(module)
.encoding::<C>()
.spawn(&path)
})
... | fim | yewstack/yew | rust |
<|fim_prefix|>/// The reachability of an agent.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Copy)]
pub enum Reach {
/// Public R<|fim_suffix|> Reachability.
Private,
}
<|fim_middle|>eachability.
Public,
/// Private<|endoftext|> | fim | yewstack/yew | rust |
<|fim_suffix|>f = on_output;
}
let tx = use_memo((worker_state, ctr.inner), |(state, _ctr)| {
let bridge = state.create_bridge();
let (tx, mut rx) = bridge.split();
spawn_local(async move {
while let Some(m) = rx.next().await {
let on_output = on_output_ref... | fim | yewstack/yew | rust |
//! This module contains the reactor agent implementation.
//!
//! Reactor agents are agents that receive multiple inputs and send multiple outputs over a single
//! bridge. A reactor is defined as an async function that takes a [ReactorScope]
//! as the argument.
//!
//! The reactor scope is a stream that produces inp... | fim | yewstack/yew | rust |
use std::any::type_name;
use std::cell::RefCell;
use std::fmt;
use std::rc::Rc;
use gloo_worker::{Bincode, Codec};
use serde::{Deserialize, Serialize};
use yew::prelude::*;
use super::{Reactor, ReactorBridge, ReactorScoped, ReactorSpawner};
use crate::Reach;
use crate::utils::get_next_id;
use crate::worker::WorkerPro... | fim | yewstack/yew | rust |
<|fim_prefix|>//! This module contains extensions to the component scope for agent access.
use std::any::type_name;
use std::fmt;
use std::rc::Rc;
use futures::stream::SplitSink;
use futures::{SinkExt, StreamExt};
use wasm_bindgen::UnwrapThrowExt;
use yew::html::Scope;
use yew::platform::pinned::RwLock;
use yew::plat... | fim | yewstack/yew | rust |
<|fim_suffix|>> {
type Action = OutputsAction<T>;
fn reduce(mut self: Rc<Self>, action: Self::Action) -> Rc<Self> {
{
let this = Rc::make_mut(&mut self);
this.ctr += 1;
match action {
OutputsAction::Push(m) => this.inner.push(m),
Outp... | fim | yewstack/yew | rust |
<|fim_suffix|>f.bridge)
.field("outputs", &self.outputs)
.finish_non_exhaustive()
}
}
impl<T> Deref for UseWorkerSubscriptionHandle<T>
where
T: Worker,
{
type Target = [Rc<T::Output>];
fn deref(&self) -> &[Rc<T::Output>] {
&self.outputs
}
}
impl<T> PartialEq for Us... | fim | yewstack/yew | rust |
<|fim_prefix|>//! This module contains the worker agent implementation.
//!
//! This is a low-level implementation that uses an actor model.
//!
//! # Example
//!
//! ```
//! # mod example {
//! use serde::{Deserialize, Serialize};
//! use yew::prelude::*;
//! use yew_agent::worker::{use_worker_bridge, UseWorkerBridgeH... | fim | yewstack/yew | rust |
<|fim_suffix|> Input: Serialize + for<'de> Deserialize<'de> + 'static,
Output: Serialize + for<'de> Deserialize<'de> + 'static,
> + 'static,
C: Codec + 'static,
{
let WorkerProviderProps {
children,
path,
lazy,
module,
reach,
} = props.c... | fim | yewstack/yew | rust |
<|fim_suffix|> return Ok(Self { agent_name: None });
}
let agent_name = input.parse()?;
Ok(Self {
agent_name: Some(agent_name),
})
}
}
<|fim_prefix|>use proc_macro2::{Span, TokenStream};
use quote::ToTokens;
use syn::parse::{Parse, ParseStream};
use syn::punc... | fim | yewstack/yew | rust |
<|fim_prefix|>use proc_macro::TokenStream;
use syn::parse_macro_input;
mod agent_fn;
mod oneshot;
mod reactor;
use agent_fn::{AgentFn, AgentName};
use oneshot::{OneshotFn, oneshot_impl};
use reactor::{React<|fim_suffix|>e]
pub fn oneshot(attr: TokenStream, item: TokenStream) -> TokenStream {
let item = parse_macr... | fim | yewstack/yew | rust |
use proc_macro2::{Span, TokenStream};
use quote::quote;
use syn::{Ident, ReturnType, Signature, Type, parse_quote};
use crate::agent_fn::{AgentFn, AgentFnType, AgentName};
pub struct OneshotFn {}
impl AgentFnType for OneshotFn {
type OutputType = Type;
type RecvType = Type;
fn attr_name() -> &'static st... | fim | yewstack/yew | rust |
<|fim_suffix|>oxed::Box::pin(
async move {
#fn_call
}
),
_marker: ::std::marker::PhantomData,
}
}
}
impl #impl_generics ::std::future::Future for #reactor_name... | fim | yewstack/yew | rust |
<|fim_prefix|>use std::any::{Any, TypeId};
use std::cell::RefCell;
use std::collections::HashMap;
#[cfg(target_arch = "wasm32")]
use std::collections::HashSet;
use std::fmt;
use std::hash::Hash;
#[cfg(target_arch = "wasm32")]
use std::num::NonZeroUsize;
use std::pin::Pin;
use std::rc::Rc;
use std::sync::Arc;
#[cfg(tar... | fim | yewstack/yew | rust |
<|fim_suffix|>: None,
error: Some(err_val),
}),
),
}
}
}
#[cfg(feature = "actix")]
pub mod actix {
use actix_web::HttpResponse;
use actix_web::web::{Data, Json};
use crate::{LinkRequest, LinkResponse, Resolver};
/// Actix handler that resolv... | fim | yewstack/yew | rust |
<|fim_prefix|>use proc_macro::TokenStream;
use proc_macro2::Span;
use quote::quote;
use syn::{FnArg, Ident, ImplItem, ImplItemFn, ItemImpl, Pat, PatType, parse_macro_input};
/// Derive a [`LinkedState`] implementation from an impl block that declares
/// `type Context`, `type Input`, and `async fn resolve`.
///
/// On... | fim | yewstack/yew | rust |
<|fim_suffix|> ..
}) => {
let value = lit_str.value();
let classes = value.split_whitespace().collect::<Vec<_>>();
if classes.len() > 1 {
let fix = classes
.into_iter()
.map(|class| forma... | fim | yewstack/yew | rust |
<|fim_suffix|>ed_site()=>
__YewToken
};
push_type_param(&mut assert_impl_generics, token_arg.clone());
let assert_impl_generics = assert_impl_generics;
let (impl_generics, _, where_clause) = assert_impl_generics.split_for_impl();
let props_mod_name = format_ident!("_... | fim | yewstack/yew | rust |
<|fim_suffix|>te! {
#[doc(hidden)]
#[allow(non_camel_case_types)]
#vis struct #check_struct<How>(::std::marker::PhantomData<How>);
#[automatically_derived]
#[diagnostic::do_not_recommend]
impl<B> ::yew::html::HasProp< #prop_name_mod :: #prop_check... | fim | yewstack/yew | rust |
<|fim_suffix|> -> GenericArgument {
GenericArgument::Type(Type::Path(TypePath {
path: Path::from(ident),
qself: None,
}))
}
<|fim_prefix|>use proc_macro2::Ident;
use syn::punctuated::Punctuated;
use syn::{GenericArgument, GenericParam, Generics, Path, Token, Type, TypePath};
/// Alias for a com... | fim | yewstack/yew | rust |
<|fim_prefix|>mod builder;
mod field;
mod generics;
mod wrapper;
use std::convert::TryInto;
use builder::PropsBuilder;
use field::PropField;
use proc_macro2::{Ident, Span};
use quote::{ToTokens, format_ident, quote};
use syn::parse::{Parse, ParseStream, Result};
use syn::punctuated::Pair;
use syn::visit_mut::VisitMut... | fim | yewstack/yew | rust |
<|fim_suffix|> ) -> Self {
PropsWrapper {
wrapper_name: name,
generics,
prop_fields,
extra_attrs,
}
}
fn field_defs(&self) -> impl Iterator<Item = impl ToTokens + '_> {
self.prop_fields.iter().map(|pf| pf.to_field_def())
}
fn de... | fim | yewstack/yew | rust |
use proc_macro2::{Span, TokenStream};
use quote::{ToTokens, quote};
use syn::parse::{Parse, ParseStream};
use syn::punctuated::Punctuated;
use syn::token::{Comma, Fn};
use syn::{
Attribute, Block, FnArg, Generics, Ident, Item, ItemFn, LitStr, ReturnType, Type, Visibility,
parse_quote, parse_quote_spanned, visit... | fim | yewstack/yew | rust |
<|fim_prefix|>use std::sync::{Arc, Mutex};
use proc_macro_error::emit_error;
use syn::spanned::Spanned;
use syn::visit_mut::VisitMut;
use syn::{
Expr, ExprCall, ExprClosure, ExprForLoop, ExprIf, ExprLoop, ExprMatch, ExprWhile, Ident, Item,
parse_quote_spanned, visit_mut,
};
#[derive(Debug)]
pub struct BodyRew... | fim | yewstack/yew | rust |
<|fim_suffix|>);
}
fn visit_type_trait_object_mut(&mut self, type_trait_obj: &mut TypeTraitObject) {
let type_trait_obj_lock = self.type_trait_obj_lock.clone();
let _locked = type_trait_obj_lock.try_lock();
visit_mut::visit_type_trait_object_mut(self, type_trait_obj);
}
fn vis... | fim | yewstack/yew | rust |
<|fim_prefix|>use proc_macro_error::emit_error;
use proc_macro2::{Span, TokenStream};
use quote::quote;
use<|fim_suffix|> let (#(#input_args,)*) = self.#args_ident;
#inner_fn_ident #call_generics (#ctx_ident, #(#input_args,)*)
}
}
#[automatically... | fim | yewstack/yew | rust |
use std::iter::once;
use std::mem::take;
use proc_macro_error::emit_error;
use proc_macro2::{Span, TokenStream};
use quote::{ToTokens, quote};
use syn::punctuated::{Pair, Punctuated};
use syn::spanned::Spanned;
use syn::visit_mut::VisitMut;
use syn::{
FnArg, GenericParam, Ident, Lifetime, LifetimeParam, Pat, Recei... | fim | yewstack/yew | rust |
<|fim_prefix|>use proc_macro2::{Delimiter, TokenStream};
use quote::{ToTokens, quote, quote_spanned};
use syn::buffer::Cursor;
use syn::parse::{Parse, ParseStream};
use syn::spanned::Spanned;
use syn::{Expr, Stmt, braced, token};
use super::{HtmlIterable, HtmlNode, ToNodeIterator};
use crate::PeekValue;
pub struct Ht... | fim | yewstack/yew | rust |
<|fim_prefix|>use proc_macro2::Span;
use quote::{ToTokens, quote, quote_spanned};
use syn::parse::discouraged::Speculative;
use syn::parse::{Parse, ParseStream};
use syn::spanned::Spanned;
use syn::{Token, Type};
use super::{HtmlChildrenTree, TagTokens};
use crate::is_ide_completion;
use crate::props::ComponentProps;
... | fim | yewstack/yew | rust |
<|fim_suffix|>idents)* };
tokens.extend(quote! { #name #extended });
}
}
impl Stringify for HtmlDashedName {
fn try_into_lit(&self) -> Option<LitStr> {
Some(self.to_lit_str())
}
fn stringify(&self) -> TokenStream {
self.to_lit_str().stringify()
}
}
impl From<Ident> for Htm... | fim | yewstack/yew | rust |
use proc_macro_error::emit_warning;
use proc_macro2::{Delimiter, Group, Span, TokenStream};
use quote::{ToTokens, quote, quote_spanned};
use syn::buffer::Cursor;
use syn::parse::{Parse, ParseStream};
use syn::spanned::Spanned;
use syn::{Expr, ExprLit, Ident, Lit, LitStr, Token};
use super::{HtmlChildrenTree, HtmlDashe... | fim | yewstack/yew | rust |
<|fim_prefix|>use proc_macro2::TokenStream;
use quote::{ToTokens, quote};
use syn::buffer::Cursor;
use syn::parse::{Parse, ParseStream};
use syn::token::{For, In};
use syn::{Expr, Pat, Stmt, braced};
use super::HtmlChildrenTree;
use super::html_loop::{emit_loop, parse_loop_body};
use crate::PeekValue;
pub struct Html... | fim | yewstack/yew | rust |
<|fim_prefix|>use proc_macro2::TokenStream;
use quote::{ToTokens, quote_spanned};
use syn::buffer::Cursor;
use syn::parse::{Parse, ParseStream};
use syn::spanned::Spanned;
use syn::{Expr, Token, parse_quote};
use super::HtmlRootBraced;
use crate::PeekValue;
pub struct HtmlIf {
if_token: Token![if],
cond: Box<... | fim | yewstack/yew | rust |
<|fim_prefix|>use proc_macro2::TokenStream;
use quote::{ToTokens, quote_spanned};
use syn::buffer::Cursor;
use syn::parse::{Parse, ParseStream};
use syn::spanned::Spanned;
use syn::{Expr, Token};
use super::ToNodeIterator;
use crate::PeekValue;
pub struct HtmlIterable(Expr);
impl PeekValue<()> for HtmlIterable {
... | fim | yewstack/yew | rust |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.