{"action":"created","comment":{"url":"https://api.github.com/repos/emberjs/guides/pulls/comments/36091972","id":36091972,"diff_hunk":"@@ -0,0 +1,105 @@\n+An `Ember.Service` is a long-lived `Ember.Object` available application-wide. Services are singletons, and only one instance of a given service can exist at a time.\n+\n+To define a service, extend the `Ember.Service` base class:\n+\n+```app/services/shopping-cart.js\n+export default Ember.Service.extend({\n+});\n+```\n+\n+Like any `Ember.Object`, a service can have properties and methods of its own.\n+\n+```app/services/shopping-cart.js\n+export default Ember.Service.extend({\n+  items: [],\n+\n+  add(item) {\n+    this.get('items').pushObject(item);\n+  },\n+\n+  remove(item) {\n+    this.get('items').removeObject(item);\n+  },\n+\n+  empty() {\n+    this.get('items').setObjects([]);\n+  }\n+});\n+```\n+\n+### Accessing services\n+\n+To access a service, inject it with `Ember.inject`:\n+\n+```app/components/cart-contents.js\n+export default Ember.Component.extend({\n+  shoppingCart: Ember.inject.service()","path":"source/services/index.md","position":36,"original_position":36,"commit_id":"daf015f9c488c6f345755a65dc006e9f6e00419a","original_commit_id":"daf015f9c488c6f345755a65dc006e9f6e00419a","user":{"login":"trek","id":9736,"avatar_url":"https://avatars.githubusercontent.com/u/9736?v=3","gravatar_id":"","url":"https://api.github.com/users/trek","html_url":"https://github.com/trek","followers_url":"https://api.github.com/users/trek/followers","following_url":"https://api.github.com/users/trek/following{/other_user}","gists_url":"https://api.github.com/users/trek/gists{/gist_id}","starred_url":"https://api.github.com/users/trek/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/trek/subscriptions","organizations_url":"https://api.github.com/users/trek/orgs","repos_url":"https://api.github.com/users/trek/repos","events_url":"https://api.github.com/users/trek/events{/privacy}","received_events_url":"https://api.github.com/users/trek/received_events","type":"User","site_admin":false},"body":"Can we teach the maximal form first `shoppingCart: Ember.inject.service('shopping-cart')` before showing the shorthand?","created_at":"2015-08-03T14:47:12Z","updated_at":"2015-08-03T14:47:12Z","html_url":"https://github.com/emberjs/guides/pull/532#discussion_r36091972","pull_request_url":"https://api.github.com/repos/emberjs/guides/pulls/532","_links":{"self":{"href":"https://api.github.com/repos/emberjs/guides/pulls/comments/36091972"},"html":{"href":"https://github.com/emberjs/guides/pull/532#discussion_r36091972"},"pull_request":{"href":"https://api.github.com/repos/emberjs/guides/pulls/532"}}},"pull_request":{"url":"https://api.github.com/repos/emberjs/guides/pulls/532","id":41470408,"html_url":"https://github.com/emberjs/guides/pull/532","diff_url":"https://github.com/emberjs/guides/pull/532.diff","patch_url":"https://github.com/emberjs/guides/pull/532.patch","issue_url":"https://api.github.com/repos/emberjs/guides/issues/532","number":532,"state":"open","locked":false,"title":"Add guide for `Ember.Service`","user":{"login":"elbeezy","id":1879691,"avatar_url":"https://avatars.githubusercontent.com/u/1879691?v=3","gravatar_id":"","url":"https://api.github.com/users/elbeezy","html_url":"https://github.com/elbeezy","followers_url":"https://api.github.com/users/elbeezy/followers","following_url":"https://api.github.com/users/elbeezy/following{/other_user}","gists_url":"https://api.github.com/users/elbeezy/gists{/gist_id}","starred_url":"https://api.github.com/users/elbeezy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/elbeezy/subscriptions","organizations_url":"https://api.github.com/users/elbeezy/orgs","repos_url":"https://api.github.com/users/elbeezy/repos","events_url":"https://api.github.com/users/elbeezy/events{/privacy}","received_events_url":"https://api.github.com/users/elbeezy/received_events","type":"User","site_admin":false},"body":"With contributions from @mattw59, @SaladFork, @ErikCH\r\n\r\nAddresses #442.\r\n\r\nNote: This replaces the old DI guide, which may deserve its own (new) section distinct from Services.","created_at":"2015-08-03T14:08:29Z","updated_at":"2015-08-03T14:47:12Z","closed_at":null,"merged_at":null,"merge_commit_sha":"525bdf784d5d84a45267b9ec41c7826fe73cbbbd","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/emberjs/guides/pulls/532/commits","review_comments_url":"https://api.github.com/repos/emberjs/guides/pulls/532/comments","review_comment_url":"https://api.github.com/repos/emberjs/guides/pulls/comments{/number}","comments_url":"https://api.github.com/repos/emberjs/guides/issues/532/comments","statuses_url":"https://api.github.com/repos/emberjs/guides/statuses/daf015f9c488c6f345755a65dc006e9f6e00419a","head":{"label":"elbeezy:feature/one-page-service-guide","ref":"feature/one-page-service-guide","sha":"daf015f9c488c6f345755a65dc006e9f6e00419a","user":{"login":"elbeezy","id":1879691,"avatar_url":"https://avatars.githubusercontent.com/u/1879691?v=3","gravatar_id":"","url":"https://api.github.com/users/elbeezy","html_url":"https://github.com/elbeezy","followers_url":"https://api.github.com/users/elbeezy/followers","following_url":"https://api.github.com/users/elbeezy/following{/other_user}","gists_url":"https://api.github.com/users/elbeezy/gists{/gist_id}","starred_url":"https://api.github.com/users/elbeezy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/elbeezy/subscriptions","organizations_url":"https://api.github.com/users/elbeezy/orgs","repos_url":"https://api.github.com/users/elbeezy/repos","events_url":"https://api.github.com/users/elbeezy/events{/privacy}","received_events_url":"https://api.github.com/users/elbeezy/received_events","type":"User","site_admin":false},"repo":{"id":40094477,"name":"guides","full_name":"elbeezy/guides","owner":{"login":"elbeezy","id":1879691,"avatar_url":"https://avatars.githubusercontent.com/u/1879691?v=3","gravatar_id":"","url":"https://api.github.com/users/elbeezy","html_url":"https://github.com/elbeezy","followers_url":"https://api.github.com/users/elbeezy/followers","following_url":"https://api.github.com/users/elbeezy/following{/other_user}","gists_url":"https://api.github.com/users/elbeezy/gists{/gist_id}","starred_url":"https://api.github.com/users/elbeezy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/elbeezy/subscriptions","organizations_url":"https://api.github.com/users/elbeezy/orgs","repos_url":"https://api.github.com/users/elbeezy/repos","events_url":"https://api.github.com/users/elbeezy/events{/privacy}","received_events_url":"https://api.github.com/users/elbeezy/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/elbeezy/guides","description":"The source for http://guides.emberjs.com","fork":true,"url":"https://api.github.com/repos/elbeezy/guides","forks_url":"https://api.github.com/repos/elbeezy/guides/forks","keys_url":"https://api.github.com/repos/elbeezy/guides/keys{/key_id}","collaborators_url":"https://api.github.com/repos/elbeezy/guides/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/elbeezy/guides/teams","hooks_url":"https://api.github.com/repos/elbeezy/guides/hooks","issue_events_url":"https://api.github.com/repos/elbeezy/guides/issues/events{/number}","events_url":"https://api.github.com/repos/elbeezy/guides/events","assignees_url":"https://api.github.com/repos/elbeezy/guides/assignees{/user}","branches_url":"https://api.github.com/repos/elbeezy/guides/branches{/branch}","tags_url":"https://api.github.com/repos/elbeezy/guides/tags","blobs_url":"https://api.github.com/repos/elbeezy/guides/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/elbeezy/guides/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/elbeezy/guides/git/refs{/sha}","trees_url":"https://api.github.com/repos/elbeezy/guides/git/trees{/sha}","statuses_url":"https://api.github.com/repos/elbeezy/guides/statuses/{sha}","languages_url":"https://api.github.com/repos/elbeezy/guides/languages","stargazers_url":"https://api.github.com/repos/elbeezy/guides/stargazers","contributors_url":"https://api.github.com/repos/elbeezy/guides/contributors","subscribers_url":"https://api.github.com/repos/elbeezy/guides/subscribers","subscription_url":"https://api.github.com/repos/elbeezy/guides/subscription","commits_url":"https://api.github.com/repos/elbeezy/guides/commits{/sha}","git_commits_url":"https://api.github.com/repos/elbeezy/guides/git/commits{/sha}","comments_url":"https://api.github.com/repos/elbeezy/guides/comments{/number}","issue_comment_url":"https://api.github.com/repos/elbeezy/guides/issues/comments{/number}","contents_url":"https://api.github.com/repos/elbeezy/guides/contents/{+path}","compare_url":"https://api.github.com/repos/elbeezy/guides/compare/{base}...{head}","merges_url":"https://api.github.com/repos/elbeezy/guides/merges","archive_url":"https://api.github.com/repos/elbeezy/guides/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/elbeezy/guides/downloads","issues_url":"https://api.github.com/repos/elbeezy/guides/issues{/number}","pulls_url":"https://api.github.com/repos/elbeezy/guides/pulls{/number}","milestones_url":"https://api.github.com/repos/elbeezy/guides/milestones{/number}","notifications_url":"https://api.github.com/repos/elbeezy/guides/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/elbeezy/guides/labels{/name}","releases_url":"https://api.github.com/repos/elbeezy/guides/releases{/id}","created_at":"2015-08-02T22:12:36Z","updated_at":"2015-08-02T22:12:37Z","pushed_at":"2015-08-03T13:32:53Z","git_url":"git://github.com/elbeezy/guides.git","ssh_url":"git@github.com:elbeezy/guides.git","clone_url":"https://github.com/elbeezy/guides.git","svn_url":"https://github.com/elbeezy/guides","homepage":null,"size":25093,"stargazers_count":0,"watchers_count":0,"language":"CSS","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"emberjs:master","ref":"master","sha":"301f89ce056a0bf9c238ba368c264ba7189ae936","user":{"login":"emberjs","id":1253363,"avatar_url":"https://avatars.githubusercontent.com/u/1253363?v=3","gravatar_id":"","url":"https://api.github.com/users/emberjs","html_url":"https://github.com/emberjs","followers_url":"https://api.github.com/users/emberjs/followers","following_url":"https://api.github.com/users/emberjs/following{/other_user}","gists_url":"https://api.github.com/users/emberjs/gists{/gist_id}","starred_url":"https://api.github.com/users/emberjs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/emberjs/subscriptions","organizations_url":"https://api.github.com/users/emberjs/orgs","repos_url":"https://api.github.com/users/emberjs/repos","events_url":"https://api.github.com/users/emberjs/events{/privacy}","received_events_url":"https://api.github.com/users/emberjs/received_events","type":"Organization","site_admin":false},"repo":{"id":22767401,"name":"guides","full_name":"emberjs/guides","owner":{"login":"emberjs","id":1253363,"avatar_url":"https://avatars.githubusercontent.com/u/1253363?v=3","gravatar_id":"","url":"https://api.github.com/users/emberjs","html_url":"https://github.com/emberjs","followers_url":"https://api.github.com/users/emberjs/followers","following_url":"https://api.github.com/users/emberjs/following{/other_user}","gists_url":"https://api.github.com/users/emberjs/gists{/gist_id}","starred_url":"https://api.github.com/users/emberjs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/emberjs/subscriptions","organizations_url":"https://api.github.com/users/emberjs/orgs","repos_url":"https://api.github.com/users/emberjs/repos","events_url":"https://api.github.com/users/emberjs/events{/privacy}","received_events_url":"https://api.github.com/users/emberjs/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/emberjs/guides","description":"The source for http://guides.emberjs.com","fork":false,"url":"https://api.github.com/repos/emberjs/guides","forks_url":"https://api.github.com/repos/emberjs/guides/forks","keys_url":"https://api.github.com/repos/emberjs/guides/keys{/key_id}","collaborators_url":"https://api.github.com/repos/emberjs/guides/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/emberjs/guides/teams","hooks_url":"https://api.github.com/repos/emberjs/guides/hooks","issue_events_url":"https://api.github.com/repos/emberjs/guides/issues/events{/number}","events_url":"https://api.github.com/repos/emberjs/guides/events","assignees_url":"https://api.github.com/repos/emberjs/guides/assignees{/user}","branches_url":"https://api.github.com/repos/emberjs/guides/branches{/branch}","tags_url":"https://api.github.com/repos/emberjs/guides/tags","blobs_url":"https://api.github.com/repos/emberjs/guides/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/emberjs/guides/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/emberjs/guides/git/refs{/sha}","trees_url":"https://api.github.com/repos/emberjs/guides/git/trees{/sha}","statuses_url":"https://api.github.com/repos/emberjs/guides/statuses/{sha}","languages_url":"https://api.github.com/repos/emberjs/guides/languages","stargazers_url":"https://api.github.com/repos/emberjs/guides/stargazers","contributors_url":"https://api.github.com/repos/emberjs/guides/contributors","subscribers_url":"https://api.github.com/repos/emberjs/guides/subscribers","subscription_url":"https://api.github.com/repos/emberjs/guides/subscription","commits_url":"https://api.github.com/repos/emberjs/guides/commits{/sha}","git_commits_url":"https://api.github.com/repos/emberjs/guides/git/commits{/sha}","comments_url":"https://api.github.com/repos/emberjs/guides/comments{/number}","issue_comment_url":"https://api.github.com/repos/emberjs/guides/issues/comments{/number}","contents_url":"https://api.github.com/repos/emberjs/guides/contents/{+path}","compare_url":"https://api.github.com/repos/emberjs/guides/compare/{base}...{head}","merges_url":"https://api.github.com/repos/emberjs/guides/merges","archive_url":"https://api.github.com/repos/emberjs/guides/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/emberjs/guides/downloads","issues_url":"https://api.github.com/repos/emberjs/guides/issues{/number}","pulls_url":"https://api.github.com/repos/emberjs/guides/pulls{/number}","milestones_url":"https://api.github.com/repos/emberjs/guides/milestones{/number}","notifications_url":"https://api.github.com/repos/emberjs/guides/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/emberjs/guides/labels{/name}","releases_url":"https://api.github.com/repos/emberjs/guides/releases{/id}","created_at":"2014-08-08T18:25:02Z","updated_at":"2015-08-02T01:21:44Z","pushed_at":"2015-08-03T14:08:29Z","git_url":"git://github.com/emberjs/guides.git","ssh_url":"git@github.com:emberjs/guides.git","clone_url":"https://github.com/emberjs/guides.git","svn_url":"https://github.com/emberjs/guides","homepage":null,"size":28357,"stargazers_count":95,"watchers_count":95,"language":"CSS","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":285,"mirror_url":null,"open_issues_count":35,"forks":285,"open_issues":35,"watchers":95,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/emberjs/guides/pulls/532"},"html":{"href":"https://github.com/emberjs/guides/pull/532"},"issue":{"href":"https://api.github.com/repos/emberjs/guides/issues/532"},"comments":{"href":"https://api.github.com/repos/emberjs/guides/issues/532/comments"},"review_comments":{"href":"https://api.github.com/repos/emberjs/guides/pulls/532/comments"},"review_comment":{"href":"https://api.github.com/repos/emberjs/guides/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/emberjs/guides/pulls/532/commits"},"statuses":{"href":"https://api.github.com/repos/emberjs/guides/statuses/daf015f9c488c6f345755a65dc006e9f6e00419a"}}}}