mirror of
https://github.com/DioxusLabs/dioxus
synced 2024-11-26 22:20:19 +00:00
simplify the crm example a bit more
This commit is contained in:
parent
fc6912d4c0
commit
f2e48f10e9
4 changed files with 9 additions and 40 deletions
|
@ -51,7 +51,7 @@ fn ClientList() -> Element {
|
|||
h2 { "List of Clients" }
|
||||
Link { to: Route::ClientAdd, class: "pure-button pure-button-primary", "Add Client" }
|
||||
Link { to: Route::Settings, class: "pure-button", "Settings" }
|
||||
for client in CLIENTS.read().iter() {
|
||||
for client in CLIENTS.iter() {
|
||||
div { class: "client", style: "margin-bottom: 50px",
|
||||
p { "Name: {client.first_name} {client.last_name}" }
|
||||
p { "Description: {client.description}" }
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
use crate::read::Readable;
|
||||
use crate::read::ReadableVecExt;
|
||||
use crate::rt::CopyValue;
|
||||
use crate::signal::Signal;
|
||||
use crate::write::Writable;
|
||||
use crate::{GlobalMemo, GlobalSignal, ReadOnlySignal, ReadableValueIterator, SignalData};
|
||||
use crate::{GlobalMemo, GlobalSignal, ReadOnlySignal, SignalData};
|
||||
use generational_box::Storage;
|
||||
|
||||
use std::{
|
||||
|
@ -124,16 +123,6 @@ impl<T: 'static, S: Storage<T>> Clone for CopyValue<T, S> {
|
|||
|
||||
impl<T: 'static, S: Storage<T>> Copy for CopyValue<T, S> {}
|
||||
|
||||
impl<T: 'static, S: Storage<Vec<T>>> IntoIterator for CopyValue<Vec<T>, S> {
|
||||
type IntoIter = ReadableValueIterator<T, Self>;
|
||||
|
||||
type Item = S::Ref<T>;
|
||||
|
||||
fn into_iter(self) -> Self::IntoIter {
|
||||
self.iter()
|
||||
}
|
||||
}
|
||||
|
||||
read_impls!(Signal, S: Storage<SignalData<T>>, S: Storage<SignalData<Vec<T>>>);
|
||||
write_impls!(Signal, Storage<SignalData<T>>, Storage<SignalData<Vec<T>>>);
|
||||
|
||||
|
@ -145,16 +134,6 @@ impl<T: 'static, S: Storage<SignalData<T>>> Clone for Signal<T, S> {
|
|||
|
||||
impl<T: 'static, S: Storage<SignalData<T>>> Copy for Signal<T, S> {}
|
||||
|
||||
impl<T: 'static, S: Storage<SignalData<Vec<T>>>> IntoIterator for Signal<Vec<T>, S> {
|
||||
type IntoIter = ReadableValueIterator<T, Self>;
|
||||
|
||||
type Item = S::Ref<T>;
|
||||
|
||||
fn into_iter(self) -> Self::IntoIter {
|
||||
self.iter()
|
||||
}
|
||||
}
|
||||
|
||||
read_impls!(
|
||||
ReadOnlySignal,
|
||||
S: Storage<SignalData<T>>,
|
||||
|
@ -169,16 +148,6 @@ impl<T: 'static, S: Storage<SignalData<T>>> Clone for ReadOnlySignal<T, S> {
|
|||
|
||||
impl<T: 'static, S: Storage<SignalData<T>>> Copy for ReadOnlySignal<T, S> {}
|
||||
|
||||
impl<T: 'static, S: Storage<SignalData<Vec<T>>>> IntoIterator for ReadOnlySignal<Vec<T>, S> {
|
||||
type IntoIter = ReadableValueIterator<T, Self>;
|
||||
|
||||
type Item = S::Ref<T>;
|
||||
|
||||
fn into_iter(self) -> Self::IntoIter {
|
||||
self.iter()
|
||||
}
|
||||
}
|
||||
|
||||
read_impls!(GlobalSignal);
|
||||
|
||||
read_impls!(GlobalMemo: PartialEq);
|
||||
|
|
|
@ -85,26 +85,26 @@ pub trait ReadableVecExt<T: 'static>: Readable<Vec<T>> {
|
|||
|
||||
/// Get an iterator over the values of the inner vector.
|
||||
#[track_caller]
|
||||
fn iter(&self) -> ReadableValueIterator<T, Self>
|
||||
fn iter(&self) -> ReadableValueIterator<'_, T, Self>
|
||||
where
|
||||
Self: Sized + Clone,
|
||||
Self: Sized,
|
||||
{
|
||||
ReadableValueIterator {
|
||||
index: 0,
|
||||
value: self.clone(),
|
||||
value: self,
|
||||
phantom: std::marker::PhantomData,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// An iterator over the values of a `Readable<Vec<T>>`.
|
||||
pub struct ReadableValueIterator<T, R> {
|
||||
pub struct ReadableValueIterator<'a, T, R> {
|
||||
index: usize,
|
||||
value: R,
|
||||
value: &'a R,
|
||||
phantom: std::marker::PhantomData<T>,
|
||||
}
|
||||
|
||||
impl<T: 'static, R: Readable<Vec<T>>> Iterator for ReadableValueIterator<T, R> {
|
||||
impl<'a, T: 'static, R: Readable<Vec<T>>> Iterator for ReadableValueIterator<'a, T, R> {
|
||||
type Item = R::Ref<T>;
|
||||
|
||||
fn next(&mut self) -> Option<Self::Item> {
|
||||
|
|
|
@ -175,7 +175,7 @@ pub trait WritableVecExt<T: 'static>: Writable<Vec<T>> {
|
|||
|
||||
/// Gets an iterator over the values of the vector.
|
||||
#[track_caller]
|
||||
fn iter(&self) -> WritableValueIterator<T, Self>
|
||||
fn iter_mut(&self) -> WritableValueIterator<T, Self>
|
||||
where
|
||||
Self: Sized + Clone,
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue