public NotifyWeakReactivePropertyViewModel(NotifyModel model) { Time = model.ObserveProperty(x => x.Time) .Select(x => $"{x} - NotifyWeakReactivePropertyViewModel") .ToWeakReactiveProperty(); Time.Subscribe(Console.WriteLine); }
public static void Main(string[] args) { IService service = new Service(); NotifyModel model = new NotifyModel(); vm1 = new StrongSubscribeViewModel(service); vm2 = new WeakSubscribeViewModel(service); vm3 = new StrongReactivePropertyViewModel(service); vm4 = new ReakReactivePropertyViewModel(service); vm5 = new NotifyStrongReactivePropertyViewModel(model); vm6 = new NotifyWeakReactivePropertyViewModel(model); service.SetTime(); model.SetTime(0); Console.WriteLine(); GC.Collect(); Console.WriteLine("GC.Collect"); Console.WriteLine(); service.SetTime(); model.SetTime(1); vm1 = null; vm2 = null; vm3 = null; vm4 = null; vm5 = null; vm6 = null; Console.WriteLine(); GC.Collect(); Console.WriteLine("GC.Collect"); Console.WriteLine(); service.SetTime(); model.SetTime(2); Console.ReadKey(); }