New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: basic TODO app; no bells, no whistles #1167
base: main
Are you sure you want to change the base?
Conversation
276552e
to
c8373e1
Compare
Would Vec.retain() be a simpler way to implement delete_todo? |
c8373e1
to
6de0c32
Compare
6de0c32
to
5b644e2
Compare
Yeah, that's a definite improvement, thank you! |
Thanks for suggesting this! When compared to the |
Maybe this could be called |
} | ||
|
||
#[derive(Copy, Clone)] | ||
struct TodoGenerator { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd split the ID, the Todo and the latest ID state.
e.g.:
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
pub struct TodoId(u64);
impl TodoId {
const fn next(self) -> Self {
Self(self.0 + 1)
}
}
impl TodoItem {
const fn new(id: TodoId, name: String) -> Self {
Self { id, name }
}
}
fn main(){
let mut current_id = TodoId::default();
// ...
let create_new_item = |title| {
let next_id = current_id.next();
current_id = next_id;
let todo = TodoItem::new(next_id, title);
};
}
@jdevries Sorry for my slow response here. Thanks for your contribution. We have created a new |
1 similar comment
@jdevries Sorry for my slow response here. Thanks for your contribution. We have created a new |
I was wishing this was present when trying to learn from the examples in the repo – just a basic client-side TODO app without any server-side code or isomorphism.
I feel like this specific implementation probably stinks – I'm totally new to both Leptos and Rust, so happy to take any feedback & no hard feelings if there isn't interest in pulling an example like this into the repo. I fully appreciate my naive perspective here :)