Re: referencing an atom inside a function used for swapping

2010-03-26 Thread Josh Stratton
> construct the JPanel outside the atom, add all the listeners and then > add the panel to structure in the atom. > > (let [panel (JPanel. ..)] >  (add-listener-stuff panel the-atom) >  (swap! the-atom assoc :SpiffyPanel panel)) > > Side-effecting things shouldn't be done inside the swap! since it

Re: referencing an atom inside a function used for swapping

2010-03-25 Thread Meikel Brandmeyer
Hi, construct the JPanel outside the atom, add all the listeners and then add the panel to structure in the atom. (let [panel (JPanel. ..)] (add-listener-stuff panel the-atom) (swap! the-atom assoc :SpiffyPanel panel)) Side-effecting things shouldn't be done inside the swap! since it can be

Re: referencing an atom inside a function used for swapping

2010-03-25 Thread Mark J. Reed
Ah, right, this is the function called from swap!. So move the listener stuff out of your swap function and into the function that calls swap! instead? On Thu, Mar 25, 2010 at 11:02 PM, Josh Stratton wrote: >> I would just pass the atom and move the @ inside the function... > > But the non-atom

Re: referencing an atom inside a function used for swapping

2010-03-25 Thread Josh Stratton
> I would just pass the atom and move the @ inside the function... But the non-atom is automatically dereferenced and sent to the respective function when I use swap! So unless there's another function to alter atoms, I'm going to have the dereferenced version there no matter what, right? > > On

Re: referencing an atom inside a function used for swapping

2010-03-25 Thread Mark J. Reed
I would just pass the atom and move the @ inside the function... On Thursday, March 25, 2010, strattonbrazil wrote: > I have a function that I use for adding a JPanel to a ui atom.  When I > call swap! that ui atom is sent to that function I call with the swap! > on and is dereferenced inside the