{"action":"opened","number":5,"pull_request":{"url":"https://api.github.com/repos/aroemers/mount-lite/pulls/5","id":59293113,"html_url":"https://github.com/aroemers/mount-lite/pull/5","diff_url":"https://github.com/aroemers/mount-lite/pull/5.diff","patch_url":"https://github.com/aroemers/mount-lite/pull/5.patch","issue_url":"https://api.github.com/repos/aroemers/mount-lite/issues/5","number":5,"state":"open","locked":false,"title":"Bindings (dependency injection), good idea?","user":{"login":"aroemers","id":1654946,"avatar_url":"https://avatars.githubusercontent.com/u/1654946?v=3","gravatar_id":"","url":"https://api.github.com/users/aroemers","html_url":"https://github.com/aroemers","followers_url":"https://api.github.com/users/aroemers/followers","following_url":"https://api.github.com/users/aroemers/following{/other_user}","gists_url":"https://api.github.com/users/aroemers/gists{/gist_id}","starred_url":"https://api.github.com/users/aroemers/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aroemers/subscriptions","organizations_url":"https://api.github.com/users/aroemers/orgs","repos_url":"https://api.github.com/users/aroemers/repos","events_url":"https://api.github.com/users/aroemers/events{/privacy}","received_events_url":"https://api.github.com/users/aroemers/received_events","type":"User","site_admin":false},"body":"From the README:\r\n\r\n### Bindings\r\n\r\nIt is generally best to define the `defstate`s in application namespaces, not in the more general (library) namespaces. This is because the `:start` and `:stop` expressions are tightly coupled to their environment, including references to other states. This is fine though, as you as the application writer have full control over your states, and resources should be at the periphery of the application anyway.\r\n\r\nYet, in the rare situations where you need a looser coupling between the `:start`/`:stop` expressions and their environment, mount-lite has a unique feature called bindings. When defining a `defstate`, one can optionally supply a `:bindings` vector, next to the `:start` and `:stop` expressions. This vector declares the bindings that can be used by the `:start`/`:stop` expressions, and their defaults. For example:\r\n\r\n```clj\r\n(defstate incrementer\r\n  :start    (fn [n] (+ n i))\r\n  :stop     (println \"stopping incrementer of\" i)\r\n  :bindings [i 10])\r\n```\r\n\r\nWhen the `incrementer` state is started normally, it will become a function that increments the argument by 10. However, one can start the `incrementer` with different bindings, like so:\r\n\r\n```clj\r\n(mount/start (bindings #'incrementer {'i 20})\r\n;=> (#'incrementer)\r\n\r\n(incrementer 5)\r\n;=> 25\r\n\r\n(stop)\r\n;>> stopping 20 incrementer\r\n;=> (#'incrementer)\r\n```\r\n\r\nAs can be seen, the bindings that were used when starting the state are also used when stopping the state.\r\n\r\nThis bindings feature can be used as a kind of dependency injection or for passing configuration parameters. Yet, at the current time of writing, my opinion is to use this feature sparingly. Substitutions are normally sufficient and using bindings a lot might hint towards a design flaw.\r\n","created_at":"2016-02-14T11:22:11Z","updated_at":"2016-02-14T11:22:11Z","closed_at":null,"merged_at":null,"merge_commit_sha":null,"assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/aroemers/mount-lite/pulls/5/commits","review_comments_url":"https://api.github.com/repos/aroemers/mount-lite/pulls/5/comments","review_comment_url":"https://api.github.com/repos/aroemers/mount-lite/pulls/comments{/number}","comments_url":"https://api.github.com/repos/aroemers/mount-lite/issues/5/comments","statuses_url":"https://api.github.com/repos/aroemers/mount-lite/statuses/c9b6e095af9eaa915fa62890255e82936e738415","head":{"label":"aroemers:bindings","ref":"bindings","sha":"c9b6e095af9eaa915fa62890255e82936e738415","user":{"login":"aroemers","id":1654946,"avatar_url":"https://avatars.githubusercontent.com/u/1654946?v=3","gravatar_id":"","url":"https://api.github.com/users/aroemers","html_url":"https://github.com/aroemers","followers_url":"https://api.github.com/users/aroemers/followers","following_url":"https://api.github.com/users/aroemers/following{/other_user}","gists_url":"https://api.github.com/users/aroemers/gists{/gist_id}","starred_url":"https://api.github.com/users/aroemers/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aroemers/subscriptions","organizations_url":"https://api.github.com/users/aroemers/orgs","repos_url":"https://api.github.com/users/aroemers/repos","events_url":"https://api.github.com/users/aroemers/events{/privacy}","received_events_url":"https://api.github.com/users/aroemers/received_events","type":"User","site_admin":false},"repo":{"id":50057402,"name":"mount-lite","full_name":"aroemers/mount-lite","owner":{"login":"aroemers","id":1654946,"avatar_url":"https://avatars.githubusercontent.com/u/1654946?v=3","gravatar_id":"","url":"https://api.github.com/users/aroemers","html_url":"https://github.com/aroemers","followers_url":"https://api.github.com/users/aroemers/followers","following_url":"https://api.github.com/users/aroemers/following{/other_user}","gists_url":"https://api.github.com/users/aroemers/gists{/gist_id}","starred_url":"https://api.github.com/users/aroemers/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aroemers/subscriptions","organizations_url":"https://api.github.com/users/aroemers/orgs","repos_url":"https://api.github.com/users/aroemers/repos","events_url":"https://api.github.com/users/aroemers/events{/privacy}","received_events_url":"https://api.github.com/users/aroemers/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/aroemers/mount-lite","description":"Mount, but with parallel start/stop, composable API and other unique features","fork":false,"url":"https://api.github.com/repos/aroemers/mount-lite","forks_url":"https://api.github.com/repos/aroemers/mount-lite/forks","keys_url":"https://api.github.com/repos/aroemers/mount-lite/keys{/key_id}","collaborators_url":"https://api.github.com/repos/aroemers/mount-lite/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/aroemers/mount-lite/teams","hooks_url":"https://api.github.com/repos/aroemers/mount-lite/hooks","issue_events_url":"https://api.github.com/repos/aroemers/mount-lite/issues/events{/number}","events_url":"https://api.github.com/repos/aroemers/mount-lite/events","assignees_url":"https://api.github.com/repos/aroemers/mount-lite/assignees{/user}","branches_url":"https://api.github.com/repos/aroemers/mount-lite/branches{/branch}","tags_url":"https://api.github.com/repos/aroemers/mount-lite/tags","blobs_url":"https://api.github.com/repos/aroemers/mount-lite/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/aroemers/mount-lite/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/aroemers/mount-lite/git/refs{/sha}","trees_url":"https://api.github.com/repos/aroemers/mount-lite/git/trees{/sha}","statuses_url":"https://api.github.com/repos/aroemers/mount-lite/statuses/{sha}","languages_url":"https://api.github.com/repos/aroemers/mount-lite/languages","stargazers_url":"https://api.github.com/repos/aroemers/mount-lite/stargazers","contributors_url":"https://api.github.com/repos/aroemers/mount-lite/contributors","subscribers_url":"https://api.github.com/repos/aroemers/mount-lite/subscribers","subscription_url":"https://api.github.com/repos/aroemers/mount-lite/subscription","commits_url":"https://api.github.com/repos/aroemers/mount-lite/commits{/sha}","git_commits_url":"https://api.github.com/repos/aroemers/mount-lite/git/commits{/sha}","comments_url":"https://api.github.com/repos/aroemers/mount-lite/comments{/number}","issue_comment_url":"https://api.github.com/repos/aroemers/mount-lite/issues/comments{/number}","contents_url":"https://api.github.com/repos/aroemers/mount-lite/contents/{+path}","compare_url":"https://api.github.com/repos/aroemers/mount-lite/compare/{base}...{head}","merges_url":"https://api.github.com/repos/aroemers/mount-lite/merges","archive_url":"https://api.github.com/repos/aroemers/mount-lite/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/aroemers/mount-lite/downloads","issues_url":"https://api.github.com/repos/aroemers/mount-lite/issues{/number}","pulls_url":"https://api.github.com/repos/aroemers/mount-lite/pulls{/number}","milestones_url":"https://api.github.com/repos/aroemers/mount-lite/milestones{/number}","notifications_url":"https://api.github.com/repos/aroemers/mount-lite/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/aroemers/mount-lite/labels{/name}","releases_url":"https://api.github.com/repos/aroemers/mount-lite/releases{/id}","deployments_url":"https://api.github.com/repos/aroemers/mount-lite/deployments","created_at":"2016-01-20T20:16:21Z","updated_at":"2016-02-14T00:27:33Z","pushed_at":"2016-02-14T11:19:06Z","git_url":"git://github.com/aroemers/mount-lite.git","ssh_url":"git@github.com:aroemers/mount-lite.git","clone_url":"https://github.com/aroemers/mount-lite.git","svn_url":"https://github.com/aroemers/mount-lite","homepage":"http://aroemers.github.io/mount-lite/","size":115,"stargazers_count":10,"watchers_count":10,"language":"Clojure","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":0,"mirror_url":null,"open_issues_count":4,"forks":0,"open_issues":4,"watchers":10,"default_branch":"master"}},"base":{"label":"aroemers:master","ref":"master","sha":"79a56fcbdd37af052f9287b4eba5566b43a3413e","user":{"login":"aroemers","id":1654946,"avatar_url":"https://avatars.githubusercontent.com/u/1654946?v=3","gravatar_id":"","url":"https://api.github.com/users/aroemers","html_url":"https://github.com/aroemers","followers_url":"https://api.github.com/users/aroemers/followers","following_url":"https://api.github.com/users/aroemers/following{/other_user}","gists_url":"https://api.github.com/users/aroemers/gists{/gist_id}","starred_url":"https://api.github.com/users/aroemers/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aroemers/subscriptions","organizations_url":"https://api.github.com/users/aroemers/orgs","repos_url":"https://api.github.com/users/aroemers/repos","events_url":"https://api.github.com/users/aroemers/events{/privacy}","received_events_url":"https://api.github.com/users/aroemers/received_events","type":"User","site_admin":false},"repo":{"id":50057402,"name":"mount-lite","full_name":"aroemers/mount-lite","owner":{"login":"aroemers","id":1654946,"avatar_url":"https://avatars.githubusercontent.com/u/1654946?v=3","gravatar_id":"","url":"https://api.github.com/users/aroemers","html_url":"https://github.com/aroemers","followers_url":"https://api.github.com/users/aroemers/followers","following_url":"https://api.github.com/users/aroemers/following{/other_user}","gists_url":"https://api.github.com/users/aroemers/gists{/gist_id}","starred_url":"https://api.github.com/users/aroemers/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aroemers/subscriptions","organizations_url":"https://api.github.com/users/aroemers/orgs","repos_url":"https://api.github.com/users/aroemers/repos","events_url":"https://api.github.com/users/aroemers/events{/privacy}","received_events_url":"https://api.github.com/users/aroemers/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/aroemers/mount-lite","description":"Mount, but with parallel start/stop, composable API and other unique features","fork":false,"url":"https://api.github.com/repos/aroemers/mount-lite","forks_url":"https://api.github.com/repos/aroemers/mount-lite/forks","keys_url":"https://api.github.com/repos/aroemers/mount-lite/keys{/key_id}","collaborators_url":"https://api.github.com/repos/aroemers/mount-lite/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/aroemers/mount-lite/teams","hooks_url":"https://api.github.com/repos/aroemers/mount-lite/hooks","issue_events_url":"https://api.github.com/repos/aroemers/mount-lite/issues/events{/number}","events_url":"https://api.github.com/repos/aroemers/mount-lite/events","assignees_url":"https://api.github.com/repos/aroemers/mount-lite/assignees{/user}","branches_url":"https://api.github.com/repos/aroemers/mount-lite/branches{/branch}","tags_url":"https://api.github.com/repos/aroemers/mount-lite/tags","blobs_url":"https://api.github.com/repos/aroemers/mount-lite/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/aroemers/mount-lite/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/aroemers/mount-lite/git/refs{/sha}","trees_url":"https://api.github.com/repos/aroemers/mount-lite/git/trees{/sha}","statuses_url":"https://api.github.com/repos/aroemers/mount-lite/statuses/{sha}","languages_url":"https://api.github.com/repos/aroemers/mount-lite/languages","stargazers_url":"https://api.github.com/repos/aroemers/mount-lite/stargazers","contributors_url":"https://api.github.com/repos/aroemers/mount-lite/contributors","subscribers_url":"https://api.github.com/repos/aroemers/mount-lite/subscribers","subscription_url":"https://api.github.com/repos/aroemers/mount-lite/subscription","commits_url":"https://api.github.com/repos/aroemers/mount-lite/commits{/sha}","git_commits_url":"https://api.github.com/repos/aroemers/mount-lite/git/commits{/sha}","comments_url":"https://api.github.com/repos/aroemers/mount-lite/comments{/number}","issue_comment_url":"https://api.github.com/repos/aroemers/mount-lite/issues/comments{/number}","contents_url":"https://api.github.com/repos/aroemers/mount-lite/contents/{+path}","compare_url":"https://api.github.com/repos/aroemers/mount-lite/compare/{base}...{head}","merges_url":"https://api.github.com/repos/aroemers/mount-lite/merges","archive_url":"https://api.github.com/repos/aroemers/mount-lite/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/aroemers/mount-lite/downloads","issues_url":"https://api.github.com/repos/aroemers/mount-lite/issues{/number}","pulls_url":"https://api.github.com/repos/aroemers/mount-lite/pulls{/number}","milestones_url":"https://api.github.com/repos/aroemers/mount-lite/milestones{/number}","notifications_url":"https://api.github.com/repos/aroemers/mount-lite/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/aroemers/mount-lite/labels{/name}","releases_url":"https://api.github.com/repos/aroemers/mount-lite/releases{/id}","deployments_url":"https://api.github.com/repos/aroemers/mount-lite/deployments","created_at":"2016-01-20T20:16:21Z","updated_at":"2016-02-14T00:27:33Z","pushed_at":"2016-02-14T11:19:06Z","git_url":"git://github.com/aroemers/mount-lite.git","ssh_url":"git@github.com:aroemers/mount-lite.git","clone_url":"https://github.com/aroemers/mount-lite.git","svn_url":"https://github.com/aroemers/mount-lite","homepage":"http://aroemers.github.io/mount-lite/","size":115,"stargazers_count":10,"watchers_count":10,"language":"Clojure","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":0,"mirror_url":null,"open_issues_count":4,"forks":0,"open_issues":4,"watchers":10,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/aroemers/mount-lite/pulls/5"},"html":{"href":"https://github.com/aroemers/mount-lite/pull/5"},"issue":{"href":"https://api.github.com/repos/aroemers/mount-lite/issues/5"},"comments":{"href":"https://api.github.com/repos/aroemers/mount-lite/issues/5/comments"},"review_comments":{"href":"https://api.github.com/repos/aroemers/mount-lite/pulls/5/comments"},"review_comment":{"href":"https://api.github.com/repos/aroemers/mount-lite/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/aroemers/mount-lite/pulls/5/commits"},"statuses":{"href":"https://api.github.com/repos/aroemers/mount-lite/statuses/c9b6e095af9eaa915fa62890255e82936e738415"}},"merged":false,"mergeable":null,"mergeable_state":"unknown","merged_by":null,"comments":0,"review_comments":0,"commits":5,"additions":90,"deletions":10,"changed_files":5}}