{"action":"created","comment":{"url":"https://api.github.com/repos/Lambda-X/lambdax-blog/pulls/comments/59617091","id":59617091,"diff_hunk":"@@ -0,0 +1,370 @@\n+{:title \"The approach to state management in Clojure\"\n+:description  \"Intro to mutable state in Clojure. Greg the llama show you an effective way how to manage state, and you'll find out that llamas love candies too :)\"\n+:layout :post\n+:tags  [\"Clojure\" \"ClojureScript\" \"Fundamentals\"]\n+:toc false\n+:author \"Dajana Štiberová\"\n+:image \"\"}\n+\n+Long time ago, during one interview, I was asked to describe the difference between `vars` and `atoms`.\n+It was a pretty simple question, but at that time it was not so easy to describe this difference for me.\n+Now I'm more skilled in Clojure but I still think that it was an interesting question and when\n+I was looking for a topic for the blog post, I decided to use this one.\n+\n+So if you want to read something about state management, or you want to know how to dance like Greg the llama, this post is for you :)\n+\n+## States and Identities\n+\n+We need to know that in Clojure there is a difference between state and identity.\n+\n+`States` are immutable data.\n+A state is the value an identity points to at a particular time. State never changes.\n+\n+`Identities` unify different values over the time.\n+Identity types are mutable references to immutable values,\n+and can be modelled by using one of the four references types (`Var`s, `Atom`s, `Agent`s, `Ref`s)\n+\n+\n+### *Example*\n+\n+Our example is the best llama on earth, Greg the llama.\n+Greg is an identity.\n+Greg wants to go to the party with Gregorina. He is a good dancer, and he wants to teach us how to dance.\n+\n+So, Greg is dancing and every *snapshot* of this action is one state.\n+\n+Greg has a series of different values (moves) over time (states 1-4).\n+We need to realize, that we can transition the state but it is not possible to change or modify the previous state.\n+The identity (Greg) can be modelled by using some reference type pointing to the value,\n+and subsequently calling the appropriate functions to create new states.\n+\n+NOTE:\n+\n+If you don't have any knowledge about threads in Clojure, you should read about [threads](http://blog.clojuregirl.com/clojure_threads.html) first.\n+\n+## How we can manage states (or how the data might change over time)\n+<div>\n+<div id=\"marshmallow-text\">","path":"resources/templates/md/posts/2016-04-04-state.md","position":47,"original_position":47,"commit_id":"2d708449766d936564996afc04a24076fa4dc4ce","original_commit_id":"2d708449766d936564996afc04a24076fa4dc4ce","user":{"login":"dstiberova","id":9211809,"avatar_url":"https://avatars.githubusercontent.com/u/9211809?v=3","gravatar_id":"","url":"https://api.github.com/users/dstiberova","html_url":"https://github.com/dstiberova","followers_url":"https://api.github.com/users/dstiberova/followers","following_url":"https://api.github.com/users/dstiberova/following{/other_user}","gists_url":"https://api.github.com/users/dstiberova/gists{/gist_id}","starred_url":"https://api.github.com/users/dstiberova/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dstiberova/subscriptions","organizations_url":"https://api.github.com/users/dstiberova/orgs","repos_url":"https://api.github.com/users/dstiberova/repos","events_url":"https://api.github.com/users/dstiberova/events{/privacy}","received_events_url":"https://api.github.com/users/dstiberova/received_events","type":"User","site_admin":false},"body":"oh, yes .. I didn't push the CSS","created_at":"2016-04-13T20:14:45Z","updated_at":"2016-04-13T20:14:45Z","html_url":"https://github.com/Lambda-X/lambdax-blog/pull/72#discussion_r59617091","pull_request_url":"https://api.github.com/repos/Lambda-X/lambdax-blog/pulls/72","_links":{"self":{"href":"https://api.github.com/repos/Lambda-X/lambdax-blog/pulls/comments/59617091"},"html":{"href":"https://github.com/Lambda-X/lambdax-blog/pull/72#discussion_r59617091"},"pull_request":{"href":"https://api.github.com/repos/Lambda-X/lambdax-blog/pulls/72"}}},"pull_request":{"url":"https://api.github.com/repos/Lambda-X/lambdax-blog/pulls/72","id":66004665,"html_url":"https://github.com/Lambda-X/lambdax-blog/pull/72","diff_url":"https://github.com/Lambda-X/lambdax-blog/pull/72.diff","patch_url":"https://github.com/Lambda-X/lambdax-blog/pull/72.patch","issue_url":"https://api.github.com/repos/Lambda-X/lambdax-blog/issues/72","number":72,"state":"open","locked":false,"title":"State management","user":{"login":"dstiberova","id":9211809,"avatar_url":"https://avatars.githubusercontent.com/u/9211809?v=3","gravatar_id":"","url":"https://api.github.com/users/dstiberova","html_url":"https://github.com/dstiberova","followers_url":"https://api.github.com/users/dstiberova/followers","following_url":"https://api.github.com/users/dstiberova/following{/other_user}","gists_url":"https://api.github.com/users/dstiberova/gists{/gist_id}","starred_url":"https://api.github.com/users/dstiberova/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dstiberova/subscriptions","organizations_url":"https://api.github.com/users/dstiberova/orgs","repos_url":"https://api.github.com/users/dstiberova/repos","events_url":"https://api.github.com/users/dstiberova/events{/privacy}","received_events_url":"https://api.github.com/users/dstiberova/received_events","type":"User","site_admin":false},"body":"Please review","created_at":"2016-04-11T14:38:51Z","updated_at":"2016-04-13T20:14:45Z","closed_at":null,"merged_at":null,"merge_commit_sha":"96b267bd3fad33652ee656ba045bbcd97d13363c","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/Lambda-X/lambdax-blog/pulls/72/commits","review_comments_url":"https://api.github.com/repos/Lambda-X/lambdax-blog/pulls/72/comments","review_comment_url":"https://api.github.com/repos/Lambda-X/lambdax-blog/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Lambda-X/lambdax-blog/issues/72/comments","statuses_url":"https://api.github.com/repos/Lambda-X/lambdax-blog/statuses/2d708449766d936564996afc04a24076fa4dc4ce","head":{"label":"Lambda-X:state-management","ref":"state-management","sha":"2d708449766d936564996afc04a24076fa4dc4ce","user":{"login":"Lambda-X","id":15338403,"avatar_url":"https://avatars.githubusercontent.com/u/15338403?v=3","gravatar_id":"","url":"https://api.github.com/users/Lambda-X","html_url":"https://github.com/Lambda-X","followers_url":"https://api.github.com/users/Lambda-X/followers","following_url":"https://api.github.com/users/Lambda-X/following{/other_user}","gists_url":"https://api.github.com/users/Lambda-X/gists{/gist_id}","starred_url":"https://api.github.com/users/Lambda-X/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Lambda-X/subscriptions","organizations_url":"https://api.github.com/users/Lambda-X/orgs","repos_url":"https://api.github.com/users/Lambda-X/repos","events_url":"https://api.github.com/users/Lambda-X/events{/privacy}","received_events_url":"https://api.github.com/users/Lambda-X/received_events","type":"Organization","site_admin":false},"repo":{"id":50098970,"name":"lambdax-blog","full_name":"Lambda-X/lambdax-blog","owner":{"login":"Lambda-X","id":15338403,"avatar_url":"https://avatars.githubusercontent.com/u/15338403?v=3","gravatar_id":"","url":"https://api.github.com/users/Lambda-X","html_url":"https://github.com/Lambda-X","followers_url":"https://api.github.com/users/Lambda-X/followers","following_url":"https://api.github.com/users/Lambda-X/following{/other_user}","gists_url":"https://api.github.com/users/Lambda-X/gists{/gist_id}","starred_url":"https://api.github.com/users/Lambda-X/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Lambda-X/subscriptions","organizations_url":"https://api.github.com/users/Lambda-X/orgs","repos_url":"https://api.github.com/users/Lambda-X/repos","events_url":"https://api.github.com/users/Lambda-X/events{/privacy}","received_events_url":"https://api.github.com/users/Lambda-X/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Lambda-X/lambdax-blog","description":"The official blog of LambdaX","fork":false,"url":"https://api.github.com/repos/Lambda-X/lambdax-blog","forks_url":"https://api.github.com/repos/Lambda-X/lambdax-blog/forks","keys_url":"https://api.github.com/repos/Lambda-X/lambdax-blog/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Lambda-X/lambdax-blog/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Lambda-X/lambdax-blog/teams","hooks_url":"https://api.github.com/repos/Lambda-X/lambdax-blog/hooks","issue_events_url":"https://api.github.com/repos/Lambda-X/lambdax-blog/issues/events{/number}","events_url":"https://api.github.com/repos/Lambda-X/lambdax-blog/events","assignees_url":"https://api.github.com/repos/Lambda-X/lambdax-blog/assignees{/user}","branches_url":"https://api.github.com/repos/Lambda-X/lambdax-blog/branches{/branch}","tags_url":"https://api.github.com/repos/Lambda-X/lambdax-blog/tags","blobs_url":"https://api.github.com/repos/Lambda-X/lambdax-blog/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Lambda-X/lambdax-blog/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Lambda-X/lambdax-blog/git/refs{/sha}","trees_url":"https://api.github.com/repos/Lambda-X/lambdax-blog/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Lambda-X/lambdax-blog/statuses/{sha}","languages_url":"https://api.github.com/repos/Lambda-X/lambdax-blog/languages","stargazers_url":"https://api.github.com/repos/Lambda-X/lambdax-blog/stargazers","contributors_url":"https://api.github.com/repos/Lambda-X/lambdax-blog/contributors","subscribers_url":"https://api.github.com/repos/Lambda-X/lambdax-blog/subscribers","subscription_url":"https://api.github.com/repos/Lambda-X/lambdax-blog/subscription","commits_url":"https://api.github.com/repos/Lambda-X/lambdax-blog/commits{/sha}","git_commits_url":"https://api.github.com/repos/Lambda-X/lambdax-blog/git/commits{/sha}","comments_url":"https://api.github.com/repos/Lambda-X/lambdax-blog/comments{/number}","issue_comment_url":"https://api.github.com/repos/Lambda-X/lambdax-blog/issues/comments{/number}","contents_url":"https://api.github.com/repos/Lambda-X/lambdax-blog/contents/{+path}","compare_url":"https://api.github.com/repos/Lambda-X/lambdax-blog/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Lambda-X/lambdax-blog/merges","archive_url":"https://api.github.com/repos/Lambda-X/lambdax-blog/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Lambda-X/lambdax-blog/downloads","issues_url":"https://api.github.com/repos/Lambda-X/lambdax-blog/issues{/number}","pulls_url":"https://api.github.com/repos/Lambda-X/lambdax-blog/pulls{/number}","milestones_url":"https://api.github.com/repos/Lambda-X/lambdax-blog/milestones{/number}","notifications_url":"https://api.github.com/repos/Lambda-X/lambdax-blog/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Lambda-X/lambdax-blog/labels{/name}","releases_url":"https://api.github.com/repos/Lambda-X/lambdax-blog/releases{/id}","deployments_url":"https://api.github.com/repos/Lambda-X/lambdax-blog/deployments","created_at":"2016-01-21T10:07:24Z","updated_at":"2016-03-24T17:44:46Z","pushed_at":"2016-04-13T18:26:09Z","git_url":"git://github.com/Lambda-X/lambdax-blog.git","ssh_url":"git@github.com:Lambda-X/lambdax-blog.git","clone_url":"https://github.com/Lambda-X/lambdax-blog.git","svn_url":"https://github.com/Lambda-X/lambdax-blog","homepage":"","size":1947,"stargazers_count":1,"watchers_count":1,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":3,"forks":0,"open_issues":3,"watchers":1,"default_branch":"master"}},"base":{"label":"Lambda-X:master","ref":"master","sha":"50f6527b4121c2457d8fbe7f66024e4e7dc30e0f","user":{"login":"Lambda-X","id":15338403,"avatar_url":"https://avatars.githubusercontent.com/u/15338403?v=3","gravatar_id":"","url":"https://api.github.com/users/Lambda-X","html_url":"https://github.com/Lambda-X","followers_url":"https://api.github.com/users/Lambda-X/followers","following_url":"https://api.github.com/users/Lambda-X/following{/other_user}","gists_url":"https://api.github.com/users/Lambda-X/gists{/gist_id}","starred_url":"https://api.github.com/users/Lambda-X/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Lambda-X/subscriptions","organizations_url":"https://api.github.com/users/Lambda-X/orgs","repos_url":"https://api.github.com/users/Lambda-X/repos","events_url":"https://api.github.com/users/Lambda-X/events{/privacy}","received_events_url":"https://api.github.com/users/Lambda-X/received_events","type":"Organization","site_admin":false},"repo":{"id":50098970,"name":"lambdax-blog","full_name":"Lambda-X/lambdax-blog","owner":{"login":"Lambda-X","id":15338403,"avatar_url":"https://avatars.githubusercontent.com/u/15338403?v=3","gravatar_id":"","url":"https://api.github.com/users/Lambda-X","html_url":"https://github.com/Lambda-X","followers_url":"https://api.github.com/users/Lambda-X/followers","following_url":"https://api.github.com/users/Lambda-X/following{/other_user}","gists_url":"https://api.github.com/users/Lambda-X/gists{/gist_id}","starred_url":"https://api.github.com/users/Lambda-X/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Lambda-X/subscriptions","organizations_url":"https://api.github.com/users/Lambda-X/orgs","repos_url":"https://api.github.com/users/Lambda-X/repos","events_url":"https://api.github.com/users/Lambda-X/events{/privacy}","received_events_url":"https://api.github.com/users/Lambda-X/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Lambda-X/lambdax-blog","description":"The official blog of LambdaX","fork":false,"url":"https://api.github.com/repos/Lambda-X/lambdax-blog","forks_url":"https://api.github.com/repos/Lambda-X/lambdax-blog/forks","keys_url":"https://api.github.com/repos/Lambda-X/lambdax-blog/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Lambda-X/lambdax-blog/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Lambda-X/lambdax-blog/teams","hooks_url":"https://api.github.com/repos/Lambda-X/lambdax-blog/hooks","issue_events_url":"https://api.github.com/repos/Lambda-X/lambdax-blog/issues/events{/number}","events_url":"https://api.github.com/repos/Lambda-X/lambdax-blog/events","assignees_url":"https://api.github.com/repos/Lambda-X/lambdax-blog/assignees{/user}","branches_url":"https://api.github.com/repos/Lambda-X/lambdax-blog/branches{/branch}","tags_url":"https://api.github.com/repos/Lambda-X/lambdax-blog/tags","blobs_url":"https://api.github.com/repos/Lambda-X/lambdax-blog/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Lambda-X/lambdax-blog/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Lambda-X/lambdax-blog/git/refs{/sha}","trees_url":"https://api.github.com/repos/Lambda-X/lambdax-blog/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Lambda-X/lambdax-blog/statuses/{sha}","languages_url":"https://api.github.com/repos/Lambda-X/lambdax-blog/languages","stargazers_url":"https://api.github.com/repos/Lambda-X/lambdax-blog/stargazers","contributors_url":"https://api.github.com/repos/Lambda-X/lambdax-blog/contributors","subscribers_url":"https://api.github.com/repos/Lambda-X/lambdax-blog/subscribers","subscription_url":"https://api.github.com/repos/Lambda-X/lambdax-blog/subscription","commits_url":"https://api.github.com/repos/Lambda-X/lambdax-blog/commits{/sha}","git_commits_url":"https://api.github.com/repos/Lambda-X/lambdax-blog/git/commits{/sha}","comments_url":"https://api.github.com/repos/Lambda-X/lambdax-blog/comments{/number}","issue_comment_url":"https://api.github.com/repos/Lambda-X/lambdax-blog/issues/comments{/number}","contents_url":"https://api.github.com/repos/Lambda-X/lambdax-blog/contents/{+path}","compare_url":"https://api.github.com/repos/Lambda-X/lambdax-blog/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Lambda-X/lambdax-blog/merges","archive_url":"https://api.github.com/repos/Lambda-X/lambdax-blog/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Lambda-X/lambdax-blog/downloads","issues_url":"https://api.github.com/repos/Lambda-X/lambdax-blog/issues{/number}","pulls_url":"https://api.github.com/repos/Lambda-X/lambdax-blog/pulls{/number}","milestones_url":"https://api.github.com/repos/Lambda-X/lambdax-blog/milestones{/number}","notifications_url":"https://api.github.com/repos/Lambda-X/lambdax-blog/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Lambda-X/lambdax-blog/labels{/name}","releases_url":"https://api.github.com/repos/Lambda-X/lambdax-blog/releases{/id}","deployments_url":"https://api.github.com/repos/Lambda-X/lambdax-blog/deployments","created_at":"2016-01-21T10:07:24Z","updated_at":"2016-03-24T17:44:46Z","pushed_at":"2016-04-13T18:26:09Z","git_url":"git://github.com/Lambda-X/lambdax-blog.git","ssh_url":"git@github.com:Lambda-X/lambdax-blog.git","clone_url":"https://github.com/Lambda-X/lambdax-blog.git","svn_url":"https://github.com/Lambda-X/lambdax-blog","homepage":"","size":1947,"stargazers_count":1,"watchers_count":1,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":3,"forks":0,"open_issues":3,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Lambda-X/lambdax-blog/pulls/72"},"html":{"href":"https://github.com/Lambda-X/lambdax-blog/pull/72"},"issue":{"href":"https://api.github.com/repos/Lambda-X/lambdax-blog/issues/72"},"comments":{"href":"https://api.github.com/repos/Lambda-X/lambdax-blog/issues/72/comments"},"review_comments":{"href":"https://api.github.com/repos/Lambda-X/lambdax-blog/pulls/72/comments"},"review_comment":{"href":"https://api.github.com/repos/Lambda-X/lambdax-blog/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Lambda-X/lambdax-blog/pulls/72/commits"},"statuses":{"href":"https://api.github.com/repos/Lambda-X/lambdax-blog/statuses/2d708449766d936564996afc04a24076fa4dc4ce"}}}}