You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It worked fine on version 10.5.43 and failed after that (>=11.*).
Steps To Reproduce
using DynamicData;using DynamicData.Binding;using ReactiveUI;using System;using System.Collections.ObjectModel;using System.Linq;using System.Reactive;using System.Reactive.Linq;using Xunit;namespaceReactiveUITests{/// <summary>/// <code>https://www.reactiveui.net/docs/handbook/message-bus/#ways-to-avoid-using-messagebus</code>/// </summary>publicclassMessageBusWaysToAvoidUsingMessageBusTest{publicclassDocumentViewModel:ReactiveObject{publicReactiveCommand<Unit,Unit> Close {get;set;}publicDocumentViewModel(){// Note that we don't actually *subscribe* to Close here or implement// anything in DocumentViewModel, because Closing is a responsibility// of the document list.Close= ReactiveCommand.Create(()=>{});}}publicclassMainViewModel:ReactiveObject{publicObservableCollection<DocumentViewModel> OpenDocuments {get;protectedset;}publicMainViewModel(){OpenDocuments=newObservableCollection<DocumentViewModel>();// Whenever the list of documents change, calculate a new Observable// to represent whenever any of the *current* documents have been// requested to close, then Switch to that. When we get something// to close, remove it from the list.
OpenDocuments
.ToObservableChangeSet().AutoRefreshOnObservable(document => document.Close).Select(_ => WhenAnyDocumentClosed()).Switch().Subscribe(x => OpenDocuments.Remove(x));}IObservable<DocumentViewModel>WhenAnyDocumentClosed(){// Select the documents into a list of Observables// who return the Document to close when signaled,// then flatten them all together.return OpenDocuments
.Select(x => x.Close.Select(_ => x)).Merge();}}[Fact]publicvoidTestWithSingleDocument(){varmain=new MainViewModel();vardoc=new DocumentViewModel();
main.OpenDocuments.Add(doc);
doc.Close.Execute().Subscribe();varactual= main.OpenDocuments.Count;
Assert.Equal(0, actual);}[Fact]publicvoidTestWithFirstFromMultipleDocuments(){varmain=new MainViewModel();vardoc=new DocumentViewModel();
main.OpenDocuments.Add(doc);
main.OpenDocuments.Add(new DocumentViewModel());
main.OpenDocuments.Add(new DocumentViewModel());
main.OpenDocuments.Add(new DocumentViewModel());
main.OpenDocuments.Add(new DocumentViewModel());
doc.Close.Execute().Subscribe();varactual= main.OpenDocuments.Count;
Assert.Equal(4, actual);}[Fact]publicvoidTestWithCenterFromMultipleDocuments(){varmain=new MainViewModel();vardoc=new DocumentViewModel();
main.OpenDocuments.Add(new DocumentViewModel());
main.OpenDocuments.Add(new DocumentViewModel());
main.OpenDocuments.Add(doc);
main.OpenDocuments.Add(new DocumentViewModel());
main.OpenDocuments.Add(new DocumentViewModel());
doc.Close.Execute().Subscribe();varactual= main.OpenDocuments.Count;
Assert.Equal(4, actual);}[Fact]publicvoidTestWithLastFromMultipleDocuments(){varmain=new MainViewModel();vardoc=new DocumentViewModel();
main.OpenDocuments.Add(new DocumentViewModel());
main.OpenDocuments.Add(new DocumentViewModel());
main.OpenDocuments.Add(new DocumentViewModel());
main.OpenDocuments.Add(new DocumentViewModel());
main.OpenDocuments.Add(doc);
doc.Close.Execute().Subscribe();varactual= main.OpenDocuments.Count;
Assert.Equal(4, actual);}}}
Environment
OS: Windows
Version 10.0.19044.1466
ReactiveUI Version: 11.* -> 17.1.17
The text was updated successfully, but these errors were encountered:
Describe the bug
The given sample from Handbook/MessageBus/Ways to avoid using MessageBus is not working. Only the last added item is handled correct (removed from the list).
It worked fine on version 10.5.43 and failed after that (>=11.*).
Steps To Reproduce
Environment
The text was updated successfully, but these errors were encountered: