@@ -53,22 +53,43 @@ public override void Execute(object parameter)
5353
5454 public class TaskLoaderCommand < T > : TaskLoaderCommandBase
5555 {
56- private readonly Func < Task < T > > _taskSource ;
56+ private readonly Func < T , Task > _taskSource ;
5757
58- public TaskLoaderCommand ( Func < Task < T > > taskSource , Func < object , bool > canExecute = null )
58+ public TaskLoaderCommand ( Func < T , Task > taskSource , Func < object , bool > canExecute = null )
5959 : base ( canExecute )
6060 {
6161 _taskSource = taskSource ;
62- Notifier = new TaskLoaderNotifier < T > ( ) ;
62+ Notifier = new TaskLoaderNotifier ( ) ;
6363 }
6464
65- public TaskLoaderNotifier < T > Notifier { get ; }
65+ public TaskLoaderNotifier Notifier { get ; }
6666
6767 protected override bool IsExecuting => ! Notifier . IsNotStarted && Notifier . IsNotCompleted ;
6868
6969 public override void Execute ( object parameter )
7070 {
71- Notifier . Load ( _taskSource ) ;
71+ Notifier . Load ( ( ) => _taskSource ( ( T ) parameter ) ) ;
72+ }
73+ }
74+
75+ public class TaskLoaderCommand < TParam , TTask > : TaskLoaderCommandBase
76+ {
77+ private readonly Func < TParam , Task < TTask > > _taskSource ;
78+
79+ public TaskLoaderCommand ( Func < TParam , Task < TTask > > taskSource , Func < object , bool > canExecute = null )
80+ : base ( canExecute )
81+ {
82+ _taskSource = taskSource ;
83+ Notifier = new TaskLoaderNotifier < TTask > ( ) ;
84+ }
85+
86+ public TaskLoaderNotifier < TTask > Notifier { get ; }
87+
88+ protected override bool IsExecuting => ! Notifier . IsNotStarted && Notifier . IsNotCompleted ;
89+
90+ public override void Execute ( object parameter )
91+ {
92+ Notifier . Load ( ( ) => _taskSource ( ( TParam ) parameter ) ) ;
7293 }
7394 }
7495}
0 commit comments