-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for AsyncActions and BroadcastActions
- Bump to 0.2.0 because it breaks some 0.1.0 apis - AsyncAction: Runs up to 4 actions - StartAction (optional) - Action itself (async task) as well as the dispatcher logic for it - FailAction or SuccessAction - BroadcastAction: explicitly mark an action as Component-only (default) or Broadcast through this marker interface:wq
- Loading branch information
Showing
15 changed files
with
212 additions
and
95 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
# Changelog | ||
|
||
## Version 0.1.3: | ||
## Version 0.2.0: | ||
|
||
- Support Async actions | ||
|
||
|
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
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
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,10 @@ | ||
package mvu.support; | ||
|
||
/** | ||
* | ||
* Marker interface for Actions which are broadcasted to all dispatchers | ||
* | ||
* Note: When applied to an AsyncAction, this means the async action will run for all dispatchers! | ||
* | ||
*/ | ||
public interface BroadcastAction extends Action {} |
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,40 @@ | ||
package mvu.support; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.function.Consumer; | ||
|
||
public class Dispatcher { | ||
|
||
final List<Consumer<Action>> parentDispatchers; | ||
|
||
final Consumer<Action> dispatcher; | ||
|
||
public Dispatcher(Consumer<Action> dispatcher){ | ||
this(new ArrayList<>(), dispatcher); | ||
} | ||
|
||
public Dispatcher(List<Consumer<Action>> parentDispatchers, Consumer<Action> dispatcher){ | ||
this.parentDispatchers = parentDispatchers; | ||
this.dispatcher = dispatcher; | ||
} | ||
|
||
public static Dispatcher empty() { | ||
return new Dispatcher(new ArrayList<>(), action -> {}); | ||
} | ||
|
||
public List<Consumer<Action>> getParentDispatchers() { | ||
return parentDispatchers; | ||
} | ||
|
||
public Consumer<Action> getDispatcher() { | ||
return dispatcher; | ||
} | ||
|
||
public List<Consumer<Action>> getAllDispatchers(){ | ||
List<Consumer<Action>> allDispatchers = new ArrayList<>(); | ||
allDispatchers.add(dispatcher); | ||
allDispatchers.addAll(parentDispatchers); | ||
return allDispatchers; | ||
} | ||
} |
Oops, something went wrong.