Fix the router and stub out a number of crates to get compiling

This commit is contained in:
Jonathan Kelley committed 2024-01-13 20:51:37 -08:00
1 parent 4c6e515da4
commit fae0b08e61
226 files changed
+1057 -1482

No files matched your search

+1 -1
View File
@@ -29,7 +29,7 @@ impl CallbackApi {
}
#[must_use]
pub fn use_atom_context(cx: &ScopeState) -> &CallbackApi {
pub fn use_atom_context() -> &CallbackApi {
todo!()
}
+4 -4
View File
@@ -1,5 +1,5 @@
use crate::{use_atom_root, AtomId, AtomRef, AtomRoot, Readable};
use dioxus_core::{ScopeId, ScopeState};
use dioxus_core::ScopeId;
use std::{
cell::{Ref, RefCell, RefMut},
rc::Rc,
@@ -101,14 +101,14 @@ impl<T: 'static> UseAtomRef<T> {
/// Example:
/// ```ignore
/// static ATOM_DATA: AtomRef<Collection> = |_| Default::default();
/// fn App(cx: Scope) {
/// fn App() {
/// use_init_atom_root(cx);
/// let atom_data = use_atom_ref(cx, ATOM_DATA);
/// let atom_data = use_atom_ref(ATOM_DATA);
/// atom_data.unsubscribe(cx);
/// atom_data.write().update();
/// }
/// ```
pub fn unsubscribe(&self, cx: &ScopeState) {
pub fn unsubscribe(&self) {
self.root.unsubscribe(self.ptr, cx.scope_id());
}
+1 -1
View File
@@ -4,7 +4,7 @@ use crate::AtomRoot;
use dioxus_core::ScopeState;
// Returns the atom root, initiaizing it at the root of the app if it does not exist.
pub fn use_atom_root(cx: &ScopeState) -> &Rc<AtomRoot> {
pub fn use_atom_root() -> &Rc<AtomRoot> {
cx.use_hook(|| match cx.consume_context::<Rc<AtomRoot>>() {
Some(root) => root,
None => panic!("No atom root found in context. Did you forget to call use_init_atom_root at the top of your app?"),
+1 -1
View File
@@ -3,7 +3,7 @@ use dioxus_core::ScopeState;
use std::rc::Rc;
// Initializes the atom root and retuns it;
pub fn use_init_atom_root(cx: &ScopeState) -> &Rc<AtomRoot> {
pub fn use_init_atom_root() -> &Rc<AtomRoot> {
cx.use_hook(|| match cx.consume_context::<Rc<AtomRoot>>() {
Some(ctx) => ctx,
None => cx.provide_context(Rc::new(AtomRoot::new(cx.schedule_update_any()))),
+4 -4
View File
@@ -1,14 +1,14 @@
use crate::{use_atom_root, AtomId, AtomRoot, Readable};
use dioxus_core::{ScopeId, ScopeState};
use dioxus_core::ScopeId;
use std::rc::Rc;
#[must_use]
pub fn use_read<V: 'static>(cx: &ScopeState, f: impl Readable<V>) -> &V {
use_read_rc(cx, f).as_ref()
pub fn use_read<V: 'static>(f: impl Readable<V>) -> &V {
use_read_rc(f).as_ref()
}
#[must_use]
pub fn use_read_rc<V: 'static>(cx: &ScopeState, f: impl Readable<V>) -> &Rc<V> {
pub fn use_read_rc<V: 'static>(f: impl Readable<V>) -> &Rc<V> {
let root = use_atom_root(cx);
struct UseReadInner<V> {
+1 -1
View File
@@ -3,7 +3,7 @@ use dioxus_core::ScopeState;
use std::rc::Rc;
#[must_use]
pub fn use_set<T: 'static>(cx: &ScopeState, f: impl Writable<T>) -> &Rc<dyn Fn(T)> {
pub fn use_set<T: 'static>(f: impl Writable<T>) -> &Rc<dyn Fn(T)> {
let root = use_atom_root(cx);
cx.use_hook(|| {
let id = f.unique_id();
+16 -16
View File
@@ -1,5 +1,5 @@
use crate::{AtomId, AtomRoot, Writable};
use dioxus_core::{ScopeId, ScopeState};
use dioxus_core::ScopeId;
use std::{
cell::RefMut,
fmt::{Debug, Display},
@@ -18,8 +18,8 @@ use std::{
/// ```ignore
/// static COUNT: Atom<u32> = |_| 0;
///
/// fn Example(cx: Scope) -> Element {
/// let mut count = use_atom_state(cx, &COUNT);
/// fn Example() -> Element {
/// let mut count = use_atom_state(&COUNT);
///
/// cx.render(rsx! {
/// div {
@@ -31,7 +31,7 @@ use std::{
/// }
/// ```
#[must_use]
pub fn use_atom_state<T: 'static>(cx: &ScopeState, f: impl Writable<T>) -> &AtomState<T> {
pub fn use_atom_state<T: 'static>(f: impl Writable<T>) -> &AtomState<T> {
let root = crate::use_atom_root(cx);
let inner = cx.use_hook(|| AtomState {
@@ -74,8 +74,8 @@ impl<T: 'static> AtomState<T> {
/// An async context might need to know the current value:
///
/// ```rust, ignore
/// fn component(cx: Scope) -> Element {
/// let count = use_state(cx, || 0);
/// fn component() -> Element {
/// let count = use_state(|| 0);
/// cx.spawn({
/// let set_count = count.to_owned();
/// async move {
@@ -103,8 +103,8 @@ impl<T: 'static> AtomState<T> {
/// A component might require an `Rc<dyn Fn(T)>` as an input to set a value.
///
/// ```rust, ignore
/// fn component(cx: Scope) -> Element {
/// let value = use_state(cx, || 0);
/// fn component() -> Element {
/// let value = use_state(|| 0);
///
/// rsx!{
/// Component {
@@ -130,8 +130,8 @@ impl<T: 'static> AtomState<T> {
/// ```rust, ignore
/// # use dioxus_core::prelude::*;
/// # use dioxus_hooks::*;
/// fn component(cx: Scope) -> Element {
/// let value = use_state(cx, || 0);
/// fn component() -> Element {
/// let value = use_state(|| 0);
///
/// // to increment the value
/// value.modify(|v| v + 1);
@@ -170,8 +170,8 @@ impl<T: 'static> AtomState<T> {
/// ```rust, ignore
/// # use dioxus_core::prelude::*;
/// # use dioxus_hooks::*;
/// fn component(cx: Scope) -> Element {
/// let value = use_state(cx, || 0);
/// fn component() -> Element {
/// let value = use_state(|| 0);
///
/// let as_rc = value.get();
/// assert_eq!(as_rc.as_ref(), &0);
@@ -192,8 +192,8 @@ impl<T: 'static> AtomState<T> {
/// Mark all consumers of this atom to re-render
///
/// ```rust, ignore
/// fn component(cx: Scope) -> Element {
/// let count = use_state(cx, || 0);
/// fn component() -> Element {
/// let count = use_state(|| 0);
/// cx.spawn({
/// let count = count.to_owned();
/// async move {
@@ -223,7 +223,7 @@ impl<T: Clone> AtomState<T> {
/// # Examples
///
/// ```ignore
/// let val = use_state(cx, || 0);
/// let val = use_state(|| 0);
///
/// val.with_mut(|v| *v = 1);
/// ```
@@ -246,7 +246,7 @@ impl<T: Clone> AtomState<T> {
/// # Examples
///
/// ```ignore
/// let val = use_state(cx, || 0);
/// let val = use_state(|| 0);
///
/// *val.make_mut() += 1;
/// ```