Component Lifecycle
public class BusyPageState : IState
{
public bool IsBusy { get; set; }
}
public class BusyPageComponent : RxComponent<BusyPageState>
{
protected override void OnMounted()
{
SetState(_ => _.IsBusy = true);
//OnMounted is called on UI Thread, move the slow code to a background thread
Task.Run(async () =>
{
//Simulate lenghty work
await Task.Delay(3000);
SetState(_ => _.IsBusy = false);
});
base.OnMounted();
}
public override VisualNode Render()
{
return new RxContentPage()
{
new RxActivityIndicator()
.VCenter()
.HCenter()
.IsRunning(State.IsBusy)
};
}
}

Last updated