Skip to content

[Bug]: ReactiveCommand.CreateFromTask #4087

@Zengshuaia

Description

@Zengshuaia

Describe the bug 🐞

my code : public MainWindowViewModel(INotificationService notificationService)
{
_notificationService = notificationService;
ToggleThemeCommand = ReactiveCommand.Create(() =>
{
ToggleTheme();
});
LoadedCommand=ReactiveCommand.CreateFromTask(async () =>
{
await Init();
});
}
public ReactiveCommand<Unit,Unit> LoadedCommand { get; set; }
private async Task Init()
{
await GetDept();
}
private async Task GetDept()
{
GetDept getDept = new GetDept();
getDept.deptcodes=GlobalParam.SysUserinfo.depts.Select(x=>x.dept_code).ToList();
string result = await HttpScheduleService.GetCommDept(JsonConvert.SerializeObject(getDept));
if (!String.IsNullOrWhiteSpace(result))
{
JsonResultModel resultModel=JsonConvert.DeserializeObject(result);
if (resultModel.code == "0")
{

        }
    }
}

Step to reproduce

Called an asynchronous method,But he made this mistake.error:An object implementing IHandleObservableErrors (often a ReactiveCommand or ObservableAsPropertyHelper) has errored, thereby breaking its observable pipeline. To prevent this, ensure the pipeline does not error, or Subscribe to the ThrownExceptions property of the object in question to handle the erroneous case.

Reproduction repository

https://github.com/reactiveui/ReactiveUI

Expected behavior

This should happen...

Screenshots 🖼️

No response

IDE

No response

Operating system

No response

Version

No response

Device

No response

ReactiveUI Version

No response

Additional information ℹ️

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions