Reverting values to their previously committed value before Reactivity propagates still triggers recomputation

Aperta
#1,421 1 commento 1 reazione 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
35/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
javascript, typescript
Ambito
frontend

Direzione di ricerca

Inizia eseguendo il Solid playground collegato e tracciando il batch call, gli aggiornamenti di signal e l’output di effect descritti nei passaggi per la riproduzione. Confronta il valore finale di signal con i calcoli che vengono eseguiti, quindi stabilisci il comportamento previsto e aggiungi o aggiorna la coverage per il ripristino di un valore all’interno di un batch.

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

Descrizione

enhancement
Describe the bug

Within a batch call, when setting a signal's value to a new value, and then back to the original value, effects are still run for the "changed" value.

This could be desired behavior, but I think an argument could be made for the behavior I'm expecting here.

The playground I've linked is a contrived example. I encountered this when trying to batch a couple store actions together, that involved this scenario of a value being changed, and then changed back to the original value at the start of the batch operation.

Your Example Website or App

https://playground.solidjs.com/anonymous/157e35f6-d812-4798-8222-082d559eec5f

Steps to Reproduce the Bug or Issue
  1. Go to the playground link
  2. Switch to the Console output in dev tools
  3. Click the 'Click' button
  4. Despite the final value of num() being unchanged at the end of batch(...), the effect is run, and the "new" value of num() is logged to the console. memoNum() naturally does not have the same issue.
Expected behavior

I expect changes to signal values within batch to be "batched", with only the end result being considered in determining what changed and what effects to run. Note that when calling setNum(0) when num() is already 0, effects are not rerun.

Sorry I know this is probably an inaccurate expectation of what batch should do. The docs description doesn't make a lot of sense to me:

# batch
Holds executing downstream computations within the block until the end to prevent unnecessary recalculation. Solid Store's set method, Mutable Store's array methods, and Effects automatically wrap their code in a batch.

Screenshots or Videos

No response

Platform

N/A

Additional context

No response

Lingua principale
TypeScript
Stelle
37k
Fork
1.2k
Merge medio
8h 43m
PR unite (30g)
365

Preparare l'ambiente

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 solidjs/solid

Tutte le issue di solidjs/solid

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.