Skip to content
Discussion options

You must be logged in to vote

Atom uses references internally (and reference equality to check for changes).

Set is a value-type and therefore is boxed when stored in an Atom, this will generate a new box every time. You could use the Observable extensions for Atom to keep a window of the last and current update, then use structural equality to check for changes.

The alternative would be to use AtomHashMap<string, Unit> (sorry, I haven't got around to writing AtomHashSet and AtomSet yet).

var atom = AtomHashMap(("A", unit), ("B", unit), ("C", unit));

atom.Change += value => Console.WriteLine(string.Join(',', value.Changes));

atom.AddOrUpdate("D", default);
atom.AddOrUpdate("E", default);
atom.AddOrUpdate("E", default);

Replies: 2 comments 4 replies

Comment options

You must be logged in to vote
1 reply
@mozesa
Comment options

Answer selected by mozesa
Comment options

You must be logged in to vote
3 replies
@CK-LinoPro
Comment options

@StefanBertels
Comment options

@louthy
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants