-
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refine global state API + TodoMVC (#36)
*add TodoMVC example *add global_state macro
- Loading branch information
1 parent
cc745c9
commit 8b76a03
Showing
28 changed files
with
1,018 additions
and
189 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
use crate::{event::*, resource::*}; | ||
use bevy::ecs::prelude::*; | ||
|
||
#[derive(Clone, Debug)] | ||
pub enum CoreCommand { | ||
CreateTodo(CreateTodo), | ||
ChangeTitle(ChangeTitle), | ||
ToggleDone(ToggleDone), | ||
RemoveTodo(RemoveTodo), | ||
ChangeFilter(ChangeFilter), | ||
ClearCompleted(ClearCompleted), | ||
ToggleAll(ToggleAll), | ||
} | ||
|
||
impl CoreCommand { | ||
pub fn create_todo(title: &String) -> Self { | ||
Self::CreateTodo(CreateTodo { | ||
title: title.clone(), | ||
}) | ||
} | ||
|
||
pub fn change_title(entity: &Entity, title: &String) -> Self { | ||
Self::ChangeTitle(ChangeTitle { | ||
entity: entity.clone(), | ||
title: title.clone(), | ||
}) | ||
} | ||
|
||
pub fn toggle_done(entity: &Entity) -> Self { | ||
Self::ToggleDone(ToggleDone { | ||
entity: entity.clone(), | ||
}) | ||
} | ||
|
||
pub fn remove_todo(entity: &Entity) -> Self { | ||
Self::RemoveTodo(RemoveTodo { | ||
entity: entity.clone(), | ||
}) | ||
} | ||
|
||
pub fn filter_all() -> Self { | ||
Self::ChangeFilter(ChangeFilter { | ||
filter: Filter::All, | ||
}) | ||
} | ||
|
||
pub fn filter_active() -> Self { | ||
Self::ChangeFilter(ChangeFilter { | ||
filter: Filter::Active, | ||
}) | ||
} | ||
|
||
pub fn filter_completed() -> Self { | ||
Self::ChangeFilter(ChangeFilter { | ||
filter: Filter::Completed, | ||
}) | ||
} | ||
|
||
pub fn toggle_all() -> Self { | ||
Self::ToggleAll(ToggleAll) | ||
} | ||
|
||
pub fn clear_completed() -> Self { | ||
Self::ClearCompleted(ClearCompleted) | ||
} | ||
} |
Oops, something went wrong.
8b76a03
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.
Successfully deployed to the following URLs:
bevy-dioxus – ./
bevy-dioxus-junichi.vercel.app
www.bevydioxus.com
bevy-dioxus-git-main-junichi.vercel.app
bevy-dioxus.com
bevydioxus.com