Git Product home page Git Product logo

Comments (10)

RolandPheasant avatar RolandPheasant commented on September 3, 2024

That's odd and clearly wrong. What version off dd, dd.reactiveui and reactiveui are you using?

from dynamicdata.reactiveui.

PureWeen avatar PureWeen commented on September 3, 2024

The master branch. All I did was pull down the master branch and write a unit test (above) into this file

https://github.com/RolandPheasant/DynamicData.ReactiveUI/blob/master/DynamicData.ReactiveUI.Tests/Fixtures/BindFromObservableListFixture.cs

namespace DynamicData.ReactiveUI.Tests.Fixtures
{
    [TestFixture]
    public class BindFromObservableListFixture
    {
        private ReactiveList<Person> _collection;
        private SourceList<Person> _source;
        private IDisposable _binder;
        private readonly RandomPersonGenerator _generator = new RandomPersonGenerator();

        [SetUp]
        public void SetUp()
        {
            _collection = new ReactiveList<Person>();
            _source = new SourceList<Person>();
            _binder = _source.Connect().Bind(_collection).Subscribe();
        }

        [TearDown]
        public void CleanUp()
        {
            _binder.Dispose();
            _source.Dispose();
        }

        [Test]
        public void DuplicatingResult()
        {

from dynamicdata.reactiveui.

PureWeen avatar PureWeen commented on September 3, 2024

though now I'm seeing that creates a double binding :-/ let me check if my test is bad

from dynamicdata.reactiveui.

PureWeen avatar PureWeen commented on September 3, 2024

Yea I did a bad job with that unit test... Let me see if I can recreate it better or if I'm just doing something wrong in my application. I was seeing this issue in my app with ReactiveList showing duplicate results in the Bound to reactive list

from dynamicdata.reactiveui.

RolandPheasant avatar RolandPheasant commented on September 3, 2024

Also in the latest dd I have moved Rx UI integration into the main dynamic data code base, so it may be that what exists in this project is out of date.

I will update the the readme to reflect this change

from dynamicdata.reactiveui.

PureWeen avatar PureWeen commented on September 3, 2024

Cool I'll work from there and see what I can recreate... Sadly unit test recreation isn't going so smooth so seeing if I can recreate in an android project

In my app basically I'm seeing this

If I use bind then I get duplicates in the ReactiveList

.ObserveOn(RxApp.MainThreadScheduler)
.Bind(SomeObservableCollectionExtended)
.Bind(SomeReactiveList); //this RL list gets duplicates

If I do it like this then everything works fine and ReactiveList doesn't get duplicates.

.ObserveOn(RxApp.MainThreadScheduler)
.Bind(SomeObservableCollectionExtended)
.Do(_ =>
{
     SomeReactiveList.Clear();
     SomeReactiveList.AddRange(SomeObservableCollectionExtended);

})

Hopefully I can easily recreate in an Android project :-)

from dynamicdata.reactiveui.

RolandPheasant avatar RolandPheasant commented on September 3, 2024

I see the problem.

The idea behind the bind operator is that dd does everything for you and you are not supposed to do any manual maintainance of the list.

This is why in all dd examples I use read-only observable collection to bind to. The observable collection extended is a throwback from earlier versions of dd.

So my question is what are you trying to achieve with the double bind?

from dynamicdata.reactiveui.

PureWeen avatar PureWeen commented on September 3, 2024

Mainly because of this issue
reactiveui/ReactiveUI#1345

I was first just binding to the ReactiveList but that was crashing on me for iOS because of that bug in ReactiveUI

so for now I stuck that bind into their and for iOS instead of allowing DynamicData to do a range add which breaks the ReactiveUI iOS CollectionSources. I do an item by item remove and add which interacts a lot better with the Reactive iOS UI components.

So basically this is what I have after accounting for iOS and cleaning it up a little by using a Readonly Collection

var activePassengerUpdates =
                Passengers
                    .Connect()
                    .DisposeMany()
                    .Filter(passengerFilter)
                    .Sort(SortExpressionComparer<CheckInRecordModel>.Ascending(p => $"{p.Priority}_{p.Passenger.LastName}_{p.Passenger.PassengerIdentifier}"))
                    .ObserveOn(RxApp.MainThreadScheduler);

if (ApplicationStateService.DeviceType == Device.iOS)
            {
                ReadOnlyObservableCollection<CheckInRecordModel> ActiveTripWaypointPassengers;
                activePassengerUpdates
                    .Bind(out ActiveTripWaypointPassengers)
                    .Do(_ =>
                    {
                        //SyncList just individually removes and adds items
                        ActiveTripWaypointPassengersRL
                            .SyncList(
                                ActiveTripWaypointPassengers,
                                x => x,
                                (x, y) => x == y,
                                null);
    
                    })
                    .Subscribe()
                    .DisposeWith(disposable);
            }
            else
            {
                activePassengerUpdates
                    .Bind(ActiveTripWaypointPassengersRL)
                    .Subscribe()
                    .DisposeWith(disposable);
            }

ActiveTripWaypointPassengersRL is what gets surfaced to the various reactive view sources and adapters.

This works great on iOS but on android my ReactiveList shows duplicate items from the source. If I change it to just use the SyncList one on Android then it works great on Android with no duplicate items

from dynamicdata.reactiveui.

PureWeen avatar PureWeen commented on September 3, 2024

And in my app I'm still using all the version 4 of things

  <package id="reactiveui" version="7.4.0" targetFramework="monoandroid71" />
  <package id="DynamicData" version="4.15.0.2299" targetFramework="monoandroid71" />
  <package id="DynamicData.ReactiveUI" version="2.5.0.2009" targetFramework="monoandroid71" />

from dynamicdata.reactiveui.

PureWeen avatar PureWeen commented on September 3, 2024

Going to close this for now. I haven't been able to create in a sample project with the latest code from the other repo. I'm still seeing the issue in my app but haven't been able to separate whether it's a me thing or a this library thing. Once I'm able to update my project to all the latest Rx netstandard bits I'll try this again and create an issue over there if applicable

from dynamicdata.reactiveui.

Related Issues (7)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.