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