active-group / active-group/reacl

Inconsistent states when there are two events in one cycle

Aberta
#47 1 comentário 0 reações 1 responsável Reivindicada por @mikesperber Ver no GitHub
bug
Linguagem predominante
Clojure
Estrelas
78
Forks
2
Métricas de merge de PRs
Nenhum PR com merge em 30d

Descrição

When two events happen "at the same time" (on one event loop), then a state cannot be updated consistently. That can happen with `onClick` on both a parent and a child (event bubbling), as in this example where the final state is not 2, but 1, although both events fire and both messages are handled:

```
(deftest bubbling-events-test
(let [c1 (reacl/class "c1" this state [& more]
render (apply dom/div
{:onclick (fn [ev]
(reacl/send-message! this :foo))}
more)

handle-message
(fn [msg]
(reacl/return :app-state (inc state))))

c2 (reacl/class "c2" this state []
render (c1 (reacl/bind this :x)
(c1 (reacl/bind this :x))))

host (js/document.createElement "div")
cc (reacl/render-component host c2 {:x 0})]

(let [inner-div (.-firstChild (.-firstChild host))]
(react-tu/Simulate.click inner-div (js/Event. "click" #js {:bubbles true :cancelable true})))

(is (= 2 (:x (test-util/extract-app-state cc))))))
```

Guia de contribuição

Nenhum guia de contribuição indexado para este repositório

Avaliação

Esta issue ainda não foi avaliada.

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.