Skip to content

Commit

Permalink
AsyncActions execution cleanup (#83)
Browse files Browse the repository at this point in the history
* moved async action to side effects

* minor refactoring
  • Loading branch information
KazaiMazai authored Sep 5, 2024
1 parent 172149b commit bbe6cd3
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,10 @@ extension AsyncAction {
}
}
}


protocol AsyncActionsExecutor {
associatedtype Action

func executeAsyncAction(_ action: Action)
}
2 changes: 2 additions & 0 deletions Sources/Puredux/Store/AnyStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ extension AnyStore {
}
}

//MARK: - AsyncActionsExecutor

extension AnyStore {
func executeAsyncAction(_ action: Action) {
guard let action = action as? (any AsyncAction) else {
Expand Down
4 changes: 3 additions & 1 deletion Sources/Puredux/Store/StateStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,9 @@ public extension StateStore {
}
}

extension StateStore {
//MARK: - AsyncActionsExecutor

extension StateStore: AsyncActionsExecutor {
func executeAsyncAction(_ action: Action) {
guard let action = action as? (any AsyncAction) else {
return
Expand Down

0 comments on commit bbe6cd3

Please sign in to comment.