`Atom().Change` fires always
Author: louthyCreated Aug 4, 2022Updated Oct 24, 2024
Labelsenhancementv5v4
Discussed in https://github.com/louthy/language-ext/discussions/1096
Originally posted by mozesa August 3, 2022
var atom = Atom(Set("A", "B", "C"));
atom.Change += value => Console.WriteLine(string.Join(',', value));
atom.Swap(old => old.Add("D"));
atom.Swap(old => old.Add("E"));
atom.Swap(old => old);A,B,C,D
A,B,C,D,E
A,B,C,D,EActually, I would like to use atom in the following context: var status = Atom(ConnectionStatus.Connected);
Now the problem is that the AtomChangedEvent<A> fires always, even if I provide swap(status, _ => ConnectionStatus.Connected).
I would like to have AtomChangedEvent<A> only when there is new value.
Source: louthy/language-ext