Skip to content

Instantly share code, notes, and snippets.

@johansson
Created October 14, 2014 19:48
Show Gist options
  • Save johansson/a68979fd2cdbfa1217b1 to your computer and use it in GitHub Desktop.
Save johansson/a68979fd2cdbfa1217b1 to your computer and use it in GitHub Desktop.
using System;
using ReactiveUI;
using System.Windows.Input;
using System.Threading;
using System.Threading.Tasks;
namespace RxUITestApp
{
public class MainVM : ReactiveObject
{
public ICommand HelloButton { get; private set; }
public MainVM()
{
HelloButton = ReactiveCommand.CreateAsyncTask(async _ => {
await Task.Run(() => {
Console.WriteLine("About to sleep!");
Thread.Sleep(5000);
Console.WriteLine("Done sleeping!");
});
});
}
}
}
// ===
using System;
using System.Drawing;
using MonoTouch.Foundation;
using MonoTouch.UIKit;
using ReactiveUI;
using System.ComponentModel;
namespace RxUITestApp
{
public partial class RxUITestAppViewController : ReactiveViewController, IViewFor<MainVM>
{
public MainVM ViewModel {
get;
set;
}
object IViewFor.ViewModel {
get {
return ViewModel;
}
set {
ViewModel = value as MainVM;
}
}
public RxUITestAppViewController(IntPtr handle) : base(handle)
{
this.ViewModel = new MainVM();
this.BindCommand(ViewModel, x => x.HelloButton, x => x.btnHello);
}
//...
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment