Bindable LINQ vs. continuous LINQ

后端 未结 6 1221
迷失自我
迷失自我 2020-12-01 05:32

What are the major difference between bindable LINQ and continuous LINQ?

•Bindable LINQ: www.codeplex.com/bindablelinq

•Continuous LINQ: www.codeplex.com/cli

6条回答
  •  無奈伤痛
    2020-12-01 06:22

    Use bindable LINQ, as it implements IDisposable, and therefore you can control when a query gets disposed. When you dispose it, all the subscriptions to INotifyPropertyChanged will unsubscribe.

    Continuous LINQ is supposed to solve this problem with weak events, but it doesn't work as far as I was able to test.

    Hmm... this seems to be a problem with bindable LINQ (the second assert fails):

    var _source = CreateSource_6People(); //(David, 27), (Mark, 15), (Steve, 30), (Jordan, 43), (Shiva, 30), (Erb, 43)
    IBindable bindable = _source.AsBindable().Sum(x => x.Age);
    var agesSum = 27+15+30+43+30+43;
    Assert.AreEqual(agesSum, bindable.Current); //PASSES
    
    _source[0].Age += 1;
    Assert.AreEqual(agesSum + 1, bindable.Current); //FAILS... DISAPPOINTING
    

提交回复
热议问题