{"action":"opened","issue":{"url":"https://api.github.com/repos/steida/este/issues/254","labels_url":"https://api.github.com/repos/steida/este/issues/254/labels{/name}","comments_url":"https://api.github.com/repos/steida/este/issues/254/comments","events_url":"https://api.github.com/repos/steida/este/issues/254/events","html_url":"https://github.com/steida/este/issues/254","id":81436372,"number":254,"title":"State class is more general concept","user":{"login":"hleumas","id":357078,"avatar_url":"https://avatars.githubusercontent.com/u/357078?v=3","gravatar_id":"","url":"https://api.github.com/users/hleumas","html_url":"https://github.com/hleumas","followers_url":"https://api.github.com/users/hleumas/followers","following_url":"https://api.github.com/users/hleumas/following{/other_user}","gists_url":"https://api.github.com/users/hleumas/gists{/gist_id}","starred_url":"https://api.github.com/users/hleumas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hleumas/subscriptions","organizations_url":"https://api.github.com/users/hleumas/orgs","repos_url":"https://api.github.com/users/hleumas/repos","events_url":"https://api.github.com/users/hleumas/events{/privacy}","received_events_url":"https://api.github.com/users/hleumas/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-05-27T13:08:22Z","updated_at":"2015-05-27T13:08:22Z","closed_at":null,"body":"Let's become familiar with Clojure atom:\r\nhttp://clojure.org/atoms\r\n\r\nIt is very similar to este `State`.\r\n**atom**\r\n    (def a (atom value)) // create new atom\r\n    (deref a) // get the value\r\n    (swap! a f arg1 arg2 ... argN) // set the new value to (f value arg1 arg2 ... argN)\r\n\r\n**State**\r\n    let a = new State(value); // create new state\r\n    a.get() // get the value\r\n    a.set(newValue) // set the new value\r\n\r\nIn both Clojure and Este, `atom`/`State` can be watched and should contain immutable values. In both of them, they can be watched for changes. \r\n\r\nHowever, I think it makes sense to separate the concepts of `atom` and `State`. First one should be thought about as general data structure, second is container for our application state. The latter needs some additional functionality beyond the `atom` (like cursors) and these should be separated.\r\n\r\nLet's create general purpose class `Atom` with a subset of `State` methods: `set`, `get`, and `constructor`. That's it. No `load`, `toConsole`, `save`, nor `cursor`."}}