SmartReactives是Rx.NET的扩展,用来检测一个表达式的值是否有变化,通过IObservable接口来检测。简单的示例代码:
var input = new ReactiveVariable<int>(1);var square = new ReactiveExpression<int>(() => input.Value * input.Value);square.Subscribe(getSquare => Console.WriteLine("square = " + getSquare())); //Prints 'square = 1'input.Value = 2; //Prints 'square = 4'input.Value = 3; //Prints 'square = 9'SmartReactives灵感来自于Scala.Rx点击空白处退出提示
评论