My approach to this was to build a GUI framework which facilitates the use of closures to capture all the state atoms. This avoids the global map. The downside of global maps is also the limitation to singletons: if the same GUI element were created twice, name clashes in the global map would be the result.
On Saturday, March 9, 2013 3:11:53 PM UTC+1, edw...@kenworthy.info wrote: > > So I understand that Clojure's data structures are immutable but I am not > clear how that works with MVC. > > So I have a view that displays a model. Other processes change that model > and the View presents those changes. > > However it's not clear to me how that would work with an immutable model. > > Obviously I can't pass the model into the View, have the view store a > reference to it and each time it's called on to render the model, do so. > The model is immutable. > > So I could have a global variable which points to the model, and whenever > I 'change' the model I re-point it to the updated version. Obviously the > view would have to reference that global. This just smells bad. And would > get worse for each model and view you needed in your application. > > I suppose you could maintain some global map of models, but that doesn't > look nice either, it's not that much different from having a pile of global > models. > > This must be a solved problem surely? Could someone point me to the > solution please? Swing or Quil based would be fine but I assume it must be > generally applicable. > -- -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.