It seems that those concepts can't be directly ported, because MVC and Observer works with changing state, and in functional programming state is usually doesn't change.
Can You please provide links to simple GUI examples that demonstrate such techniques, like the TODO list for Backbone.js? On Wednesday, October 31, 2012 4:09:41 AM UTC+4, Alexey Petrushin wrote: > > MVC / Observer in Immutable Data > > Can You please explain what are analogues of MVC / Observer techniques in > two cases: > > 1. Immutable Objects (OOP style) > 2. Immutable Data (functional style) > > For example let's consider following simple GUI example (You can try it > live here http://tinkerbin.com/0XDHRXIl click 'Run' button to start it > and wait 2 sec for text to appear) > > It's built with JavaScript because it's easy to play and MVC / Observer > are very natural to it > > // Model containing the data. > var Post = Backbone.Model.extend({}) > > var PostView = Backbone.View.extend({ > initialize: function() { > // Registering view rendering method as > // an observer on the model. > this.model.on('all', this.render.bind(this)) > }, > // Every time state of model changes > // this method will be called. > render: function() { > // Printing value of model.text attriubute. > this.$el.html(this.model.get('text')) > return this > } > }) > > // Now, any time the model is updated the view will be also > // automatically updated. > post.set({text: "hello, it's me"}) > > But I don't quite understand how to do the same with Immutable OOP and > Functional styles, what ways are there? > > Thanks, Alex. > -- 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