Skip to content

[Feature]: Provide Bind() options to choose whether to Remove/Add or Update  #641

Description

@RolandPheasant

Describe the functionality desired 🐞

Originally for Cache.Bind() for unsorted streams, an update was achieved by removing the original item and adding the updated item at the end of the list. This behaviour was changed here: #381 to fix this issue #378 .

However, it was a mistake to do this as some platforms do not support replace notifications, and some users have reported issues (including #640). Instead, we should revert to the original default remove / add, and provide an option for a consumer to opt-in to using replace.

This will be addressed by an extra param on the bind methods

// use replace for updates
var collection = new ObservableCollectionExtended<MyType>();
using var binder = source.Connect().Bind(collection, useReplaceForUpdates: true).Subscribe();

// use remove / add for updates
var collection = new ObservableCollectionExtended<MyType>();
using var binder = source.Connect().Bind(collection).Subscribe();

Similarly for ReadOnlyObservableCollection

// use replace for updates
using var binder = source.Connect().Bind(var out myReadonly, useReplaceForUpdates: true).Subscribe();

// use remove / add for updates
using var binder = source.Connect().Bind(var out myReadonly).Subscribe();

The steps the functionality will provide

Described in the description

Considerations

It will break some users, but the reverting to the original is the best solution

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions