コード例 #1
0
        public static Task Execute(
            this IReactiveElement self,
            Property <bool> isSubmitting,
            Property <Exception?> submitError,
            Func <Task> action,
            Action?onSuccessSync,
            Action <Exception>?onErrorSync = null)
        {
            Func <Task>?           onSuccess = null;
            Func <Exception, Task>?onError   = null;

            if (onSuccessSync != null)
            {
                onSuccess = () =>
                {
                    onSuccessSync();
                    return(Task.CompletedTask);
                };
            }

            if (onErrorSync != null)
            {
                onError = (exception) =>
                {
                    onErrorSync(exception);
                    return(Task.CompletedTask);
                };
            }

            return(self.Execute(isSubmitting, submitError, action, onSuccess, onError));
        }
コード例 #2
0
        public static Task Execute(
            this IReactiveElement self,
            Property <bool> isSubmitting,
            Property <Exception?> submitError,
            Func <Task> action,
            Func <Task>?onSuccess          = null,
            Func <Exception, Task>?onError = null)
        {
            async Task <bool> BoolAction()
            {
                await action();

                return(true);
            }

            Func <bool, Task>?onBoolSuccess = null;

            if (onSuccess != null)
            {
                onBoolSuccess = _ => onSuccess();
            }

            return(self.Execute(isSubmitting, submitError, BoolAction, onBoolSuccess, onError));
        }