state.rs 682 B

123456789101112131415161718192021222324252627
  1. use crate::recoil::*;
  2. pub static TODOS: AtomFamily<uuid::Uuid, TodoItem> = atom_family(|_| {});
  3. pub static FILTER: Atom<FilterState> = atom(|_| FilterState::All);
  4. #[derive(PartialEq)]
  5. pub enum FilterState {
  6. All,
  7. Active,
  8. Completed,
  9. }
  10. #[derive(Debug, PartialEq, Clone)]
  11. pub struct TodoItem {
  12. pub id: uuid::Uuid,
  13. pub checked: bool,
  14. pub contents: String,
  15. }
  16. impl crate::recoil::RecoilContext<()> {
  17. pub fn add_todo(&self, contents: String) {}
  18. pub fn remove_todo(&self) {}
  19. pub fn select_all_todos(&self) {}
  20. pub fn toggle_todo(&self, id: uuid::Uuid) {}
  21. pub fn clear_completed(&self) {}
  22. pub fn set_filter(&self, filter: &FilterState) {}
  23. }