Skip to content

[Bug]: WhenActivated from the Reactive package doesn't provide a CompositeDisposable #4434

Description

@Qonstrukt

Describe the bug 🐞

While trying to upgrade to ReactiveUI 24, I ran into the issue that DynamicData doesn't seem to be updated yet to use the Primitives. This makes it impossible to upgrade to the Primitives it seems. Fine for now, since I can use the .Reactive packages right? Well... it mostly works, except that WhenActivated apparently already expects to provide a MultipleDisposables instance, while DisposeWith doesn't know what that is.

Step to reproduce

  1. Swap out ReactiveUI 23.x with ReactiveUI.Reative 24.x
  2. Import the ReactiveUI.Reactive namespace everywhere necessary
  3. Error CS1503 : Argument 2: cannot convert from 'System.Action<System.IDisposable>' to 'System.Reactive.Disposables.CompositeDisposable'

The error references the other overload, which is also not compatible of course.

Reproduction

Something simple as this doesn't compile:

using System;
using System.Reactive.Disposables.Fluent;
using ReactiveUI.Reactive;

namespace Test;

public sealed class MyViewModel : ReactiveObject, IActivatableViewModel
{
    public ViewModelActivator Activator { get; } = new();
    
    private string _testProperty;
    public string TestProperty {
        get => _testProperty;
        private set => this.RaiseAndSetIfChanged(ref _testProperty, value);
    }

    public MyViewModel()
    {
        this.WhenActivated(d => {
            this.WhenAnyValue(vm => vm.TestProperty)
                .Subscribe(_ => {})
                .DisposeWith(d);
        });
    }
}

Expected behavior

I would expect to have a WhenActivated overload that supplies an old-fashioned CompositeDisposable.

Screenshots 🖼️

No response

IDE

Rider macOS

Operating system

No response

Version

No response

Device

No response

ReactiveUI Version

24.1.0

Additional information ℹ️

After upgrading I had to do some digging to find there is a ReactiveUI.Primitives repository that includes great documentation for migration. Would be nice to reference this existence from the ReactiveUI release notes! (Or did I miss something?)
Maybe also mention not to migrate yet if you're using DynamicData, which is a recommended dependency.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions