Ejemplo n.º 1
0
            protected override async Task OnProcess(Func <AppState> getState, LoginAction action, IMultiDispatcher dispatcher, CancellationToken cancellationToken)
            {
                List <Friend> friends = new List <Friend>();

                try
                {
                    cancellationToken.ThrowIfCancellationRequested();

                    dispatcher.DispatchImmediate(new LoadingFriendListAction());
                    var state = getState();

                    friends = await _friendService.GetFriends(state.UserName, state.AuthToken).AsCancelable(cancellationToken).ConfigureAwait(false);
                }
                finally
                {
                    dispatcher.Dispatch(new AddToFriendListAction(friends));
                }
            }
Ejemplo n.º 2
0
 /// <summary>
 /// Further processing after `UpdateTodoText` has beed dispatched.
 /// </summary>
 /// <param name="getState">Function to get the latest state.</param>
 /// <param name="action">Instance of action that is being dispatched.</param>
 /// <param name="dispatcher">Multi-Dispatcher</param>
 /// <param name="cancellationToken">Cancelation token that can be used to cancel validation step.</param>
 /// <returns>Awaitable task.</returns>
 protected override Task OnProcess(Func <TodoList> getState, UpdateTodoText action, IMultiDispatcher dispatcher, CancellationToken cancellationToken)
 {
     dispatcher.Dispatch(new HideTodoEditor(action.Id));
     return(Task.CompletedTask);
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Hook to modify logic to decide what happens when validation error occurs. Default implementation is to dispatch the error
 /// and let reducers/UI to decide.
 /// </summary>
 /// <param name="e">Validation error.</param>
 /// <param name="action">Action which got validated.</param>
 /// <param name="dispatcher">Multi-dispatcher.</param>
 protected virtual void OnValidationError(ValidationException e, TAction action, IMultiDispatcher dispatcher)
 {
     dispatcher.Dispatch(e);
 }