Skip to content
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

RxCommands with asynchronous handlers should be await able #16

Closed
lemoony opened this issue Mar 26, 2019 · 2 comments
Closed

RxCommands with asynchronous handlers should be await able #16

lemoony opened this issue Mar 26, 2019 · 2 comments

Comments

@lemoony
Copy link

lemoony commented Mar 26, 2019

Hey, first of all: Thank you for this library, it's already immensely useful.

I think it would great if RxCommands with asynchronous handlers are awaitable. This way, one can compose more complex RxCommands from simpler one. E.g.:

RxCommand<User, void> updateUser = RxCommand.createAsyncNoResult<User>({ // ... });
RxCommand<void, void> synchronize = RxCommand.createAsyncNoParamNoResult({ // ... });

RxCommand<User, void> doStuff =  RxCommand.createAsyncNoResult(() {
      await updateUser(...);
      await synchronize();
});
anaisbetts added a commit to anaisbetts/rx_command that referenced this issue Mar 28, 2019
`next` is a new property which lets us await on the next invocation of
the command. This is nice on its own, as well as making it easier to
chain RxCommands together.

Fixes fluttercommunity#16
@anaisbetts
Copy link
Contributor

Good idea! I've added a sketch of this feature in #18

anaisbetts added a commit to anaisbetts/rx_command that referenced this issue Mar 28, 2019
`next` is a new property which lets us await on the next invocation of
the command. This is nice on its own, as well as making it easier to
chain RxCommands together.

Fixes fluttercommunity#16
@lemoony
Copy link
Author

lemoony commented Apr 2, 2019

Great, thanks!

What do you think about returning the next property also from the call function?

Future<TResult> call([TParam param]) => execute(param);

Otherwise, we have to first call execute() and then await on the next property instead of just await on the execute method.

Not sure however if this may introduce some unwanted side effects.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants