// for uGUI(from 4.6) #if !(UNITY_4_0 || UNITY_4_1 || UNITY_4_2 || UNITY_4_3 || UNITY_4_4 || UNITY_4_5) /// <summary> /// Bind AsyncRaectiveCommand to button's interactable and onClick. /// </summary> public static IDisposable BindTo(this AsyncReactiveCommand <Unit> command, UnityEngine.UI.Button button) { IDisposable d1 = command.CanExecute.SubscribeToInteractable(button); IDisposable d2 = button.OnClickAsObservable().SubscribeWithState(command, (x, c) => c.Execute(x)); return(StableCompositeDisposable.Create(d1, d2)); }
/// <summary> /// Bind AsyncRaectiveCommand to button's interactable and onClick and register async action to command. /// </summary> public static IDisposable BindToOnClick(this AsyncReactiveCommand <Unit> command, UnityEngine.UI.Button button, Func <Unit, IObservable <Unit> > asyncOnClick) { var d1 = command.CanExecute.SubscribeToInteractable(button); var d2 = button.OnClickAsObservable().SubscribeWithState(command, (x, c) => c.Execute(x)); var d3 = command.Subscribe(asyncOnClick); return(StableCompositeDisposable.Create(d1, d2, d3)); }
public static IDisposable BindTo(this AsyncReactiveCommand <Unit> command, Button button) { IDisposable disposable = command.CanExecute.SubscribeToInteractable(button); IDisposable disposable2 = button.OnClickAsObservable().SubscribeWithState(command, delegate(Unit x, AsyncReactiveCommand <Unit> c) { c.Execute(x); }); return(StableCompositeDisposable.Create(disposable, disposable2)); }
public Subscription(AsyncReactiveCommand <T> parent, Func <T, IObservable <Unit> > asyncAction) { this.parent = parent; this.asyncAction = asyncAction; }