RxCommands with asynchronous handlers should be await able
lemoony opened this issue · 2 comments
lemoony commented
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 commented
Good idea! I've added a sketch of this feature in #18
lemoony commented
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.