Switch publishes the removals and the new source's items as two changesets

Aperta
#1,150 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
45/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
csharp
Ambito
backend

Direzione di ricerca

Start with Cache/Internal/Switch.cs and trace how the old-source removals are enqueued and how subscribing to the new source publishes its initial items. Check the list Switch implementation for the same sequence. The issue is done when switching publishes removals and additions as one changeset, without the intermediate empty state; no test path is named in the issue.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Switching to a new source is published as two changesets rather than one: a set of removals for what the previous source contributed, and then whatever the new source publishes when it is subscribed to.

Cache/Internal/Switch.cs, roughly:

using (var scope = queue.AcquireLock())
{
    sourceId = ++activeSourceId;

    if (current.Count != 0)
    {
        scope.EnqueueNext(/* removals for everything the old source contributed */);
        current.Clear();
    }
}

subscription.Disposable = source.SubscribeSafe(...);

The removals are enqueued, and then the subscription to the new source happens. If subscribing causes an immediate publication of the items already in that source, which it normally will, those arrive as a second changeset.

That breaks the general rule of one frame, one changeset. A subscriber sees the collection empty out and then refill, rather than a single changeset carrying the removals and the additions together. Anything binding to the result gets a visible flicker, and anything counting changesets sees two where it should see one.

The same is true of the implementation currently on main, which does destination.Clear() in a Do on the outer sequence before PopulateInto sees anything from the new source, so this is long standing rather than newly introduced.

Raised from review on #1137, where the observation was that the fix belongs in its own change rather than being folded into a completion fix.

The list Switch has the same shape and would want the same treatment.

Lingua principale
C#
Stelle
1.9k
Fork
194
Merge medio
12m
PR unite (30g)
1

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di reactivemarbles/DynamicData

Tutte le issue di reactivemarbles/DynamicData

Issue simili

Altre issue su C#

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.