Skip to content

Commit

Permalink
Fix some typos
Browse files Browse the repository at this point in the history
  • Loading branch information
AMNRG committed Dec 16, 2024
1 parent 3ec73b0 commit 76dfad1
Show file tree
Hide file tree
Showing 18 changed files with 36 additions and 30 deletions.
14 changes: 10 additions & 4 deletions packages/sycamore-futures/src/suspense.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,25 +133,31 @@ pub fn create_suspense_task(f: impl Future<Output = ()> + 'static) {
});
}

/// Create a new suspense scope that is detatched from the rest of the suspense hierarchy.
/// Create a new suspense scope that is detached from the rest of the suspense hierarchy.
///
/// This is useful if you want the result of this suspense to be independent of the praent suspense
/// This is useful if you want the result of this suspense to be independent of the parent suspense
/// scope.
///
/// It is rarely recommended to use this fucntion as it can lead to unexpected behavior when using
/// It is rarely recommended to use this function as it can lead to unexpected behavior when using
/// server side rendering, and in particular, streaming. Instead, use [`create_suspense_scope`].
///
/// The reason for this is because we generally expect outer suspenses to be resolved first before
/// an inner suspense is resolved, since otherwise we would have no place to show the inner suspense
/// as the outer fallback is still being displayed.
pub fn create_detatched_suspense_scope<T>(f: impl FnOnce() -> T) -> (T, SuspenseScope) {
pub fn create_detached_suspense_scope<T>(f: impl FnOnce() -> T) -> (T, SuspenseScope) {
let scope = SuspenseScope::new(None);
provide_context_in_new_scope(scope, move || {
let ret = f();
(ret, scope)
})
}

// TODO: remove this in the next major version
#[deprecated="Please use `create_detached_suspense_scope` instead"]
pub fn create_detatched_suspense_scope<T>(f: impl FnOnce() -> T) -> (T, SuspenseScope) {
create_detached_suspense_scope(f)
}

/// Calls the given function and registers all suspense tasks.
///
/// Returns a tuple containing the return value of the function and the created suspense scope.
Expand Down
6 changes: 3 additions & 3 deletions packages/sycamore-macro/src/props.rs
Original file line number Diff line number Diff line change
Expand Up @@ -655,7 +655,7 @@ mod struct_info {
);
});

let descructuring = self.included_fields().map(|f| f.name);
let destructuring = self.included_fields().map(|f| f.name);

let helper_trait_name = &self.conversion_helper_trait_name;
// The default of a field can refer to earlier-defined fields, which we handle by
Expand Down Expand Up @@ -684,7 +684,7 @@ mod struct_info {
// I'd prefer “a” or “an” to “its”, but determining which is grammatically
// correct is roughly impossible.
let doc =
format!("Finalise the builder and create its [`{}`] instance", name);
format!("Finalize the builder and create its [`{}`] instance", name);
quote!(#[doc = #doc])
}
}
Expand All @@ -703,7 +703,7 @@ mod struct_info {
#doc
#[allow(clippy::default_trait_access)]
pub fn build(self) -> #name #ty_generics {
let ( #(#descructuring,)* ) = self.fields;
let ( #(#destructuring,)* ) = self.fields;
#( #assignments )*
#name {
#( #field_names, )*
Expand Down
2 changes: 1 addition & 1 deletion packages/sycamore-reactive/src/effects.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ pub fn create_effect(f: impl FnMut() + 'static) {
/// ```
///
/// Note that the initial function is also called within the effect scope. This means that signals
/// created within the initial function will no longer be alive in subsequet runs. If you want to
/// created within the initial function will no longer be alive in subsequent runs. If you want to
/// create signals that are alive in subsequent runs, you should use
/// [`use_current_scope`](crate::use_current_scope) and
/// [`NodeHandle::run_in`](crate::NodeHandle::run_in).
Expand Down
2 changes: 1 addition & 1 deletion packages/sycamore-reactive/src/maybe_dyn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ impl<T: Into<Self>, U: Into<MaybeDyn<T>> + Clone> From<Signal<U>> for MaybeDyn<T
}
}

// TODO: add #[diagnostic::do_not_recommend] when it is stablised.
// TODO: add #[diagnostic::do_not_recommend] when it is stabilized.
impl<F, U, T: Into<Self>> From<F> for MaybeDyn<T>
where
F: Fn() -> U + 'static,
Expand Down
2 changes: 1 addition & 1 deletion packages/sycamore-reactive/src/memos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ pub fn create_memo<T>(f: impl FnMut() -> T + 'static) -> ReadSignal<T> {

/// Creates a memoized value from some signals.
///
/// Unlike [`create_memo`], this function will not notify dependents of a hange if the output is the
/// Unlike [`create_memo`], this function will not notify dependents of a change if the output is the
/// same. That is why the output of the function must implement [`PartialEq`].
///
/// To specify a custom comparison function, use [`create_selector_with`].
Expand Down
2 changes: 1 addition & 1 deletion packages/sycamore-reactive/src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ new_key_type! {
pub(crate) struct NodeId;
}

/// A reactive node inside the reactive grpah.
/// A reactive node inside the reactive graph.
pub(crate) struct ReactiveNode {
/// Value of the node, if any. If this node is a signal, should have a value.
pub value: Option<Box<dyn Any>>,
Expand Down
4 changes: 2 additions & 2 deletions packages/sycamore-reactive/src/root.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ pub(crate) struct Root {
pub nodes: RefCell<SlotMap<NodeId, ReactiveNode>>,
/// A list of signals who need their values to be propagated after the batch is over.
pub node_update_queue: RefCell<Vec<NodeId>>,
/// Whether we are currently batching signal updatse. If this is true, we do not run
/// Whether we are currently batching signal updates. If this is true, we do not run
/// `effect_queue` and instead wait until the end of the batch.
pub batching: Cell<bool>,
}
Expand Down Expand Up @@ -167,7 +167,7 @@ impl Root {
nodes_mut[current].dependents = dependents;
}

/// If there are no cyclic dependencies, then the reactive graph is a DAG (Directed Acylic
/// If there are no cyclic dependencies, then the reactive graph is a DAG (Directed Acyclic
/// Graph). We can therefore use DFS to get a topological sorting of all the reactive nodes.
///
/// We then go through every node in this topological sorting and update only those nodes which
Expand Down
6 changes: 3 additions & 3 deletions packages/sycamore-reactive/src/signals.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ pub struct Signal<T: 'static>(pub(crate) ReadSignal<T>);
/// There are many other ways of getting and setting signals, such as
/// [`.with(...)`](ReadSignal::with) and [`.update(...)`](Signal::update) which can access the
/// signal even if it does not implement [`Clone`] or if you simply don't want to pay the
/// performance overhead of cloning your value everytime you read it.
/// performance overhead of cloning your value every time you read it.
///
/// # Reactivity
/// What makes signals so powerful, as opposed to some other wrapper type like
Expand All @@ -105,7 +105,7 @@ pub struct Signal<T: 'static>(pub(crate) ReadSignal<T>);
/// # Ownership
/// Signals are always associated with a reactive node. This is what performs the memory management
/// for the actual value of the signal. What is returned from this function is just a
/// handle/reference to the signal allocted in the reactive node. This allows us to freely copy this
/// handle/reference to the signal allocated in the reactive node. This allows us to freely copy this
/// handle around and use it in closures and event handlers without worrying about ownership of the
/// signal.
///
Expand Down Expand Up @@ -515,7 +515,7 @@ impl<T> Signal<T> {
self.update(move |val| *val = f(val));
}

/// Split the signal into a reader/writter pair.
/// Split the signal into a reader/writer pair.
///
/// # Example
/// ```
Expand Down
4 changes: 2 additions & 2 deletions packages/sycamore-router/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ mod tests {
}

#[test]
fn ingnore_query_params_dyn() {
fn ignore_query_params_dyn() {
check(
"/a/b/c?foo=bar",
RoutePath::new(vec![DynSegments]),
Expand All @@ -384,7 +384,7 @@ mod tests {
}

#[test]
fn ingnore_hash_dyn() {
fn ignore_hash_dyn() {
check(
"/a/b/c#foo",
RoutePath::new(vec![DynSegments]),
Expand Down
2 changes: 1 addition & 1 deletion packages/sycamore-router/src/router.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ impl Integration for HistoryIntegration {

// Check if a has `rel="external"`.
if a.rel() == "external" {
// Use default browser behaviour.
// Use default browser behavior.
return;
}

Expand Down
2 changes: 1 addition & 1 deletion packages/sycamore-web/src/attributes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ impl AttributeValue for StringAttribute {
}
}

/// Type alias respresenting a possibly dynamic boolean value.
/// Type alias representing a possibly dynamic boolean value.
pub type BoolAttribute = MaybeDyn<bool>;
impl AttributeValue for BoolAttribute {
fn set_self(self, el: &mut HtmlNode, name: Cow<'static, str>) {
Expand Down
2 changes: 1 addition & 1 deletion packages/sycamore-web/src/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ where
}
}

/// Marker trait to workaround specialisation.
/// Marker trait to workaround specialization.
#[doc(hidden)]
#[cfg(feature = "suspense")]
pub struct AsyncHandler;
Expand Down
4 changes: 2 additions & 2 deletions packages/sycamore-web/src/iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ where

// Run the initial function in the outer scope, not the effect scope.
// This is because we might want to create signals and other things managed by the reactive
// tree that will be used in furture triggers of this effect. These things must therefore
// tree that will be used in future triggers of this effect. These things must therefore
// live as long as the effect.
let scope = use_current_scope();
create_effect_initial(move || {
Expand Down Expand Up @@ -202,7 +202,7 @@ where

// Run the initial function in the outer scope, not the effect scope.
// This is because we might want to create signals and other things managed by the reactive
// tree that will be used in furture triggers of this effect. These things must therefore
// tree that will be used in future triggers of this effect. These things must therefore
// live as long as the effect.
let scope = use_current_scope();
create_effect_initial(move || {
Expand Down
2 changes: 1 addition & 1 deletion packages/sycamore-web/src/resource.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! Async resources integrted with suspense.
//! Async resources integrated with suspense.
use std::future::Future;
use std::ops::Deref;
Expand Down
2 changes: 1 addition & 1 deletion packages/sycamore-web/src/stable_counter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ struct CounterValue {
/// Get the next counter value. This is stable across client and server side.
///
/// The counter is stored in the global scope so that it is shared across the entire app. It is
/// initialized to 0 and incremented everytime this function is called.
/// initialized to 0 and incremented every time this function is called.
pub fn use_stable_counter() -> u32 {
let global_scope = use_global_scope();
let counter = global_scope.run_in(|| use_context_or_else(CounterValue::default));
Expand Down
6 changes: 3 additions & 3 deletions packages/sycamore-web/src/suspense.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::future::Future;
use std::num::NonZeroU32;

use sycamore_futures::{
create_detatched_suspense_scope, create_suspense_scope, create_suspense_task,
create_detached_suspense_scope, create_suspense_scope, create_suspense_task,
};
use sycamore_macro::{component, Props};

Expand Down Expand Up @@ -196,9 +196,9 @@ pub fn Transition(props: SuspenseProps) -> View {
// TODO: Workaround for https://github.com/sycamore-rs/sycamore/issues/718.
let mut set_is_loading = set_is_loading;

// We create a detatched suspense scope here to not create a deadlock with the outer
// We create a detached suspense scope here to not create a deadlock with the outer
// suspense.
let (children, scope) = create_detatched_suspense_scope(move || children.call());
let (children, scope) = create_detached_suspense_scope(move || children.call());
// Trigger the outer suspense scope. Note that this is only triggered on the initial render
// and future renders will be captured by the inner suspense scope.
create_suspense_task(scope.until_finished());
Expand Down
2 changes: 1 addition & 1 deletion packages/sycamore-web/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ pub fn get_nodes_between(start: &web_sys::Node, end: &web_sys::Node) -> Vec<web_
///
/// This is useful when the view is dynamically changed without being mounted since this will not
/// update the DOM. Wrapping the nodes in a document fragment will allow you to dynamically update
/// the view while it is detatched, and then insert it into the DOM later.
/// the view while it is detached, and then insert it into the DOM later.
///
/// This only works on the client side.
pub fn wrap_in_document_fragment(view: View) -> View {
Expand Down
2 changes: 1 addition & 1 deletion packages/sycamore/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
//! - `serde` - Enables serializing and deserializing `Signal`s and other wrapper types using
//! `serde`.
//!
//! - `suspense` - Enalbes suspense and resources. Also enables wrappers around
//! - `suspense` - Enables suspense and resources. Also enables wrappers around
//! `wasm-bindgen-futures` to make it easier to extend a reactive scope into an `async` function.
//!
//! - `nightly` - Enables nightly-only features. This makes it slightly more ergonomic to use
Expand Down

0 comments on commit 76dfad1

Please sign in to comment.