freactive.core icon indicating copy to clipboard operation
freactive.core copied to clipboard

Inconsistencies in freactive lens-cursor and cursor behavior

Open sparkofreason opened this issue 10 years ago • 3 comments

Please see the code in this gist: https://gist.github.com/sparkofreason/25845cd249af4188a75f

Here's the output:

lc: {:c 2, :d 3}
b(lens-cursor): (assoc! state :b {:c ...})
b(lens-cursor): (reset! state {:a 2 :b {:c ...}})
b(lens-cursor): (reset! state {:a 2 :b {:c ...}})

Seems to be two related issues here. First, a child cursor derived from a lens-cursor containing a map doesn't seem to get notified the same as a child lens-cursor derived from a lens-cursor. Similarly, there is different child notification behavior whether we assoc! into the root atom, or just reset! the whole atom.

sparkofreason avatar Jun 16 '15 21:06 sparkofreason

I get this output:

lc: {:c 2, :d 3}
b(lens-cursor): (assoc! state :b {:c ...})
b(lens-cursor): (reset! state {:a 2 :b {:c ...}})
b(cursor): (reset! state {:a 2 :b {:c ...}})

Is this what you get? Still we're not seeing anything for b(cursor): (assoc! state :b {:c ...}) as would be expected.

aaronc avatar Jun 16 '15 22:06 aaronc

Sorry, copy/paste error. I get the same output as you.

sparkofreason avatar Jun 16 '15 23:06 sparkofreason

Probably closely related: calling assoc! on a lens-cursor containing a map does not trigger notifications. Using swap! will fire notifications.

sparkofreason avatar Jun 17 '15 23:06 sparkofreason