You want to read about pass by value vs. reference. In short maps are passed by reference, so folks are 'sharing' the map. Anyone that changes the map, all get the change. If you want to copy it you need to do something like
Map newMap = [:]+oldmap
Now atomicState in HE is 'special', in that it is its own copy of the data. This is an HEism on on atomicState works.
You also cannot do atomicState.remove('key'). You need to
Map tempMap=atomicState.someMap
tempMap.remove(key)
atomicState.someMap=tempMap
In general, if you can avoid atomicState, you will make your life simpler and reduce load on the hub.
Is this true if a Map is passed as a parameter to a method? If the Map is modified within the method, is the modified data then available at the level of the caller?
Very good information, thanks for sharing. I was under the mistaken impression that doing state.myNewMap = myOldMap was basically a database write. So the idea that changing myOldMap after the "database write" was rather wierd. This was the solution I came up with after a little reading.