这段 RxUI 代码有什么问题?
What's wrong with this RxUI code?
我是 RxUI 的新手,我不知道为什么没有在此代码上调用 onComplete:
Refresh = ReactiveCommand.CreateAsyncTask( o => studentsService.Students(Status, SearchText));
Refresh.Subscribe(studs =>
{
Students.Clear();
foreach (var stud in studs)
Students.Add(stud);
}, exception => DebugHelper.WriteException(exception),
async () =>
{
//this is never invoked???
foreach (var student in Students)
student.PhotoIdentity = (await studentsService.Pic(student.StudentGuid));
});
studentsService.Students() 的签名:
public async Task<IEnumerable<Student>> Students(List<StudentStatus> status, string searchString = default(string), int take = 30, int skip = 0)
当订阅 ReactiveCommand
时,每次执行所述命令时都会通知一次,并且此可观察流永远不会完成(因为命令可能随时执行)。
因此您注意到的行为符合预期,也许您只需要将 OnComplete 代码移至 OnNext 部分即可?
我是 RxUI 的新手,我不知道为什么没有在此代码上调用 onComplete:
Refresh = ReactiveCommand.CreateAsyncTask( o => studentsService.Students(Status, SearchText));
Refresh.Subscribe(studs =>
{
Students.Clear();
foreach (var stud in studs)
Students.Add(stud);
}, exception => DebugHelper.WriteException(exception),
async () =>
{
//this is never invoked???
foreach (var student in Students)
student.PhotoIdentity = (await studentsService.Pic(student.StudentGuid));
});
studentsService.Students() 的签名:
public async Task<IEnumerable<Student>> Students(List<StudentStatus> status, string searchString = default(string), int take = 30, int skip = 0)
当订阅 ReactiveCommand
时,每次执行所述命令时都会通知一次,并且此可观察流永远不会完成(因为命令可能随时执行)。
因此您注意到的行为符合预期,也许您只需要将 OnComplete 代码移至 OnNext 部分即可?