Cysharp / ObservableCollections

High performance observable collections and synchronized views, for WPF, Blazor, Unity.
MIT License
606 stars 46 forks source link

Request R3 with ISynchronizedView #78

Closed kyubuns closed 1 month ago

kyubuns commented 1 month ago

I want to create a view in Unity as follows.

var view = observableList.CreateView(x => new GameObject(x));
view
    .ObserveViewChanged() // <- I want this
    .SubscribeAwait(async (x, ct) =>
    {
        if (x.Action == NotifyCollectionChangedAction.Add)
        {
            await AddAnimation(args.NewItem.View, ct);
        }
        if (x.Action == NotifyCollectionChangedAction.Remove)
        {
            await RemoveAnimation(args.OldItem.View, ct);
            Destroy(args.OldItem.View);
        }
    })
    .AddTo(this);

However, I didn't know the best way to pass the ref struct SynchronizedViewChangedEventArgs to a Task (or to an Observable), so I would be happy if there was an official implementation.

neuecc commented 1 month ago

Thank you for the request, in v3.2.0 added ObserveChanged().

kyubuns commented 1 month ago

@neuecc Thanks for the implementation! Oops, this PR was another request to Subscribe in R3 to ISynchronizedView...!

neuecc commented 1 month ago

Oh, sorry! I’ll check it.

neuecc commented 1 month ago

v3.3.0 added subscribe view event feature.