{"action":"created","comment":{"url":"https://api.github.com/repos/n3-charts/line-chart/pulls/comments/31382573","id":31382573,"diff_hunk":"@@ -0,0 +1,111 @@\n+/// <reference path='../app.ts' />\n+\n+module n3Charts.Utils {\n+  'use strict';\n+\n+  export interface IFactory {\n+    init(key: string, em: EventManager, fm: FactoryManager);\n+    create();\n+    update();\n+    destroy();\n+  }\n+\n+  export interface IFactoryEntry {\n+    key: string;\n+    instance: IFactory;\n+  }\n+\n+  export class BaseFactory implements IFactory {\n+\n+    protected key: string;\n+    protected fm: FactoryManager;\n+    protected em: EventManager;\n+\n+    init(key:string, em: EventManager, fm: FactoryManager) {\n+      this.key = key;\n+      this.em = em;\n+      this.fm = fm;\n+\n+      // Create namespaced event listener\n+      // and bind a proper this statement\n+      this.em.on('create.' + this.key, this.create.bind(this));\n+      this.em.on('update.' + this.key, this.update.bind(this));\n+      this.em.on('destroy.' + this.key, this.destroy.bind(this));\n+    }\n+\n+    create() {\n+      // This methods need to be overwritten by factories\n+    }\n+\n+    update() {\n+      // This methods need to be overwritten by factories\n+    }\n+\n+    destroy() {\n+      // This methods need to be overwritten by factories\n+    }\n+  }\n+\n+  export class FactoryManager {\n+\n+    // A stack of all factories, preserves order\n+    private _factoryStack: IFactoryEntry[] = [];\n+\n+    index(factoryKey: string): number {\n+      // Return the index of a factory by the factoryKey\n+      return this._factoryStack\n+        .map((d) => d.key)\n+        .indexOf(factoryKey);\n+    }\n+\n+    get(factoryKey: string): any {\n+      // Get the index of the factory\n+      var index = this.index(factoryKey);\n+\n+      // Return the factory instance\n+      if (index > -1) {\n+        return this._factoryStack[index].instance;\n+      }\n+\n+      // Well, no factory found\n+      return null;\n+    }\n+\n+    all(): IFactoryEntry[] {\n+      // Return the complete stack\n+      return this._factoryStack;\n+    }\n+\n+    register(key: string, constructor: any, ...args:any[]): FactoryManager {\n+      // This generates a new factory constructor, applying\n+      // the additional args to the original constructor;\n+      // it preserves the name of the original constructor\n+      var factory = constructor.bind.apply(constructor, [null].concat(args));\n+\n+      // Let's create a new instance of the factory\n+      var instance = new factory();\n+\n+      // and push the entry to the factory stack\n+      this._factoryStack.push({\n+        key: key,\n+        instance: instance\n+      });\n+\n+      // Support chaining\n+      return this;\n+    }\n+\n+    unregister(factoryKey): FactoryManager {\n+      // Get the index of the factory\n+      var index = this.index(factoryKey);\n+\n+      // And delete the factory\n+      if (index > -1) {\n+        delete this._factoryStack[index];\n+      }\n+\n+      // Support chaining\n+      return this;","path":"src/utils/Factory.ts","position":108,"original_position":108,"commit_id":"eb4acc58a8b6463affdb8fb3d4c3d2f6b561b997","original_commit_id":"eb4acc58a8b6463affdb8fb3d4c3d2f6b561b997","user":{"login":"lorem--ipsum","id":1224709,"avatar_url":"https://avatars.githubusercontent.com/u/1224709?v=3","gravatar_id":"","url":"https://api.github.com/users/lorem--ipsum","html_url":"https://github.com/lorem--ipsum","followers_url":"https://api.github.com/users/lorem--ipsum/followers","following_url":"https://api.github.com/users/lorem--ipsum/following{/other_user}","gists_url":"https://api.github.com/users/lorem--ipsum/gists{/gist_id}","starred_url":"https://api.github.com/users/lorem--ipsum/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lorem--ipsum/subscriptions","organizations_url":"https://api.github.com/users/lorem--ipsum/orgs","repos_url":"https://api.github.com/users/lorem--ipsum/repos","events_url":"https://api.github.com/users/lorem--ipsum/events{/privacy}","received_events_url":"https://api.github.com/users/lorem--ipsum/received_events","type":"User","site_admin":false},"body":"hell yeah","created_at":"2015-05-30T17:11:51Z","updated_at":"2015-05-30T17:11:51Z","html_url":"https://github.com/n3-charts/line-chart/pull/243#discussion_r31382573","pull_request_url":"https://api.github.com/repos/n3-charts/line-chart/pulls/243","_links":{"self":{"href":"https://api.github.com/repos/n3-charts/line-chart/pulls/comments/31382573"},"html":{"href":"https://github.com/n3-charts/line-chart/pull/243#discussion_r31382573"},"pull_request":{"href":"https://api.github.com/repos/n3-charts/line-chart/pulls/243"}}},"pull_request":{"url":"https://api.github.com/repos/n3-charts/line-chart/pulls/243","id":36567448,"html_url":"https://github.com/n3-charts/line-chart/pull/243","diff_url":"https://github.com/n3-charts/line-chart/pull/243.diff","patch_url":"https://github.com/n3-charts/line-chart/pull/243.patch","issue_url":"https://api.github.com/repos/n3-charts/line-chart/issues/243","number":243,"state":"open","locked":false,"title":" Proposed structure now executable typescript","user":{"login":"chaosmail","id":2969388,"avatar_url":"https://avatars.githubusercontent.com/u/2969388?v=3","gravatar_id":"","url":"https://api.github.com/users/chaosmail","html_url":"https://github.com/chaosmail","followers_url":"https://api.github.com/users/chaosmail/followers","following_url":"https://api.github.com/users/chaosmail/following{/other_user}","gists_url":"https://api.github.com/users/chaosmail/gists{/gist_id}","starred_url":"https://api.github.com/users/chaosmail/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chaosmail/subscriptions","organizations_url":"https://api.github.com/users/chaosmail/orgs","repos_url":"https://api.github.com/users/chaosmail/repos","events_url":"https://api.github.com/users/chaosmail/events{/privacy}","received_events_url":"https://api.github.com/users/chaosmail/received_events","type":"User","site_admin":false},"body":"Hi Sébastien,\r\n\r\nfirst thanks for your awesome and super quick work to provide this awesome new infrastructure. I did my best to add the new proposed structure into this framework. Honestly, it is awesome working with so much cool stuff like gulp, node, typescript etc. it is motivating me a lot.\r\n\r\nPlease mind, we need to check on the following things:\r\n* check names for angular services, modules and directives\r\n* unify file names for src/ and dirnames (lowercase, uppercase, ..)\r\n* check the module names, class names and interface names\r\n* check the structure (is BaseFactory in module utils, etc)\r\n* gulp tasks\r\n* how to provide a minified version\r\n\r\nI will add more useful tests soon; I just wanted to provide you early access to my code.\r\n\r\nBest,\r\nChristoph","created_at":"2015-05-30T15:50:40Z","updated_at":"2015-05-30T17:11:51Z","closed_at":null,"merged_at":null,"merge_commit_sha":"5a8ba54a9a2f9705a88e68bc37f6dcf1c554b7c6","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/n3-charts/line-chart/pulls/243/commits","review_comments_url":"https://api.github.com/repos/n3-charts/line-chart/pulls/243/comments","review_comment_url":"https://api.github.com/repos/n3-charts/line-chart/pulls/comments{/number}","comments_url":"https://api.github.com/repos/n3-charts/line-chart/issues/243/comments","statuses_url":"https://api.github.com/repos/n3-charts/line-chart/statuses/eb4acc58a8b6463affdb8fb3d4c3d2f6b561b997","head":{"label":"chaosmail:dev","ref":"dev","sha":"eb4acc58a8b6463affdb8fb3d4c3d2f6b561b997","user":{"login":"chaosmail","id":2969388,"avatar_url":"https://avatars.githubusercontent.com/u/2969388?v=3","gravatar_id":"","url":"https://api.github.com/users/chaosmail","html_url":"https://github.com/chaosmail","followers_url":"https://api.github.com/users/chaosmail/followers","following_url":"https://api.github.com/users/chaosmail/following{/other_user}","gists_url":"https://api.github.com/users/chaosmail/gists{/gist_id}","starred_url":"https://api.github.com/users/chaosmail/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chaosmail/subscriptions","organizations_url":"https://api.github.com/users/chaosmail/orgs","repos_url":"https://api.github.com/users/chaosmail/repos","events_url":"https://api.github.com/users/chaosmail/events{/privacy}","received_events_url":"https://api.github.com/users/chaosmail/received_events","type":"User","site_admin":false},"repo":{"id":35663987,"name":"line-chart","full_name":"chaosmail/line-chart","owner":{"login":"chaosmail","id":2969388,"avatar_url":"https://avatars.githubusercontent.com/u/2969388?v=3","gravatar_id":"","url":"https://api.github.com/users/chaosmail","html_url":"https://github.com/chaosmail","followers_url":"https://api.github.com/users/chaosmail/followers","following_url":"https://api.github.com/users/chaosmail/following{/other_user}","gists_url":"https://api.github.com/users/chaosmail/gists{/gist_id}","starred_url":"https://api.github.com/users/chaosmail/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chaosmail/subscriptions","organizations_url":"https://api.github.com/users/chaosmail/orgs","repos_url":"https://api.github.com/users/chaosmail/repos","events_url":"https://api.github.com/users/chaosmail/events{/privacy}","received_events_url":"https://api.github.com/users/chaosmail/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/chaosmail/line-chart","description":"Awesome charts for AngularJS.","fork":true,"url":"https://api.github.com/repos/chaosmail/line-chart","forks_url":"https://api.github.com/repos/chaosmail/line-chart/forks","keys_url":"https://api.github.com/repos/chaosmail/line-chart/keys{/key_id}","collaborators_url":"https://api.github.com/repos/chaosmail/line-chart/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/chaosmail/line-chart/teams","hooks_url":"https://api.github.com/repos/chaosmail/line-chart/hooks","issue_events_url":"https://api.github.com/repos/chaosmail/line-chart/issues/events{/number}","events_url":"https://api.github.com/repos/chaosmail/line-chart/events","assignees_url":"https://api.github.com/repos/chaosmail/line-chart/assignees{/user}","branches_url":"https://api.github.com/repos/chaosmail/line-chart/branches{/branch}","tags_url":"https://api.github.com/repos/chaosmail/line-chart/tags","blobs_url":"https://api.github.com/repos/chaosmail/line-chart/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/chaosmail/line-chart/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/chaosmail/line-chart/git/refs{/sha}","trees_url":"https://api.github.com/repos/chaosmail/line-chart/git/trees{/sha}","statuses_url":"https://api.github.com/repos/chaosmail/line-chart/statuses/{sha}","languages_url":"https://api.github.com/repos/chaosmail/line-chart/languages","stargazers_url":"https://api.github.com/repos/chaosmail/line-chart/stargazers","contributors_url":"https://api.github.com/repos/chaosmail/line-chart/contributors","subscribers_url":"https://api.github.com/repos/chaosmail/line-chart/subscribers","subscription_url":"https://api.github.com/repos/chaosmail/line-chart/subscription","commits_url":"https://api.github.com/repos/chaosmail/line-chart/commits{/sha}","git_commits_url":"https://api.github.com/repos/chaosmail/line-chart/git/commits{/sha}","comments_url":"https://api.github.com/repos/chaosmail/line-chart/comments{/number}","issue_comment_url":"https://api.github.com/repos/chaosmail/line-chart/issues/comments{/number}","contents_url":"https://api.github.com/repos/chaosmail/line-chart/contents/{+path}","compare_url":"https://api.github.com/repos/chaosmail/line-chart/compare/{base}...{head}","merges_url":"https://api.github.com/repos/chaosmail/line-chart/merges","archive_url":"https://api.github.com/repos/chaosmail/line-chart/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/chaosmail/line-chart/downloads","issues_url":"https://api.github.com/repos/chaosmail/line-chart/issues{/number}","pulls_url":"https://api.github.com/repos/chaosmail/line-chart/pulls{/number}","milestones_url":"https://api.github.com/repos/chaosmail/line-chart/milestones{/number}","notifications_url":"https://api.github.com/repos/chaosmail/line-chart/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/chaosmail/line-chart/labels{/name}","releases_url":"https://api.github.com/repos/chaosmail/line-chart/releases{/id}","created_at":"2015-05-15T08:54:23Z","updated_at":"2015-05-15T08:54:24Z","pushed_at":"2015-05-30T16:37:20Z","git_url":"git://github.com/chaosmail/line-chart.git","ssh_url":"git@github.com:chaosmail/line-chart.git","clone_url":"https://github.com/chaosmail/line-chart.git","svn_url":"https://github.com/chaosmail/line-chart","homepage":"http://n3-charts.github.io/line-chart/","size":12460,"stargazers_count":0,"watchers_count":0,"language":"CoffeeScript","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"n3-charts:dev","ref":"dev","sha":"5ef20aa3aecfc0e987deb25dbab1a41c47cb2d7f","user":{"login":"n3-charts","id":4318902,"avatar_url":"https://avatars.githubusercontent.com/u/4318902?v=3","gravatar_id":"","url":"https://api.github.com/users/n3-charts","html_url":"https://github.com/n3-charts","followers_url":"https://api.github.com/users/n3-charts/followers","following_url":"https://api.github.com/users/n3-charts/following{/other_user}","gists_url":"https://api.github.com/users/n3-charts/gists{/gist_id}","starred_url":"https://api.github.com/users/n3-charts/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/n3-charts/subscriptions","organizations_url":"https://api.github.com/users/n3-charts/orgs","repos_url":"https://api.github.com/users/n3-charts/repos","events_url":"https://api.github.com/users/n3-charts/events{/privacy}","received_events_url":"https://api.github.com/users/n3-charts/received_events","type":"Organization","site_admin":false},"repo":{"id":9873034,"name":"line-chart","full_name":"n3-charts/line-chart","owner":{"login":"n3-charts","id":4318902,"avatar_url":"https://avatars.githubusercontent.com/u/4318902?v=3","gravatar_id":"","url":"https://api.github.com/users/n3-charts","html_url":"https://github.com/n3-charts","followers_url":"https://api.github.com/users/n3-charts/followers","following_url":"https://api.github.com/users/n3-charts/following{/other_user}","gists_url":"https://api.github.com/users/n3-charts/gists{/gist_id}","starred_url":"https://api.github.com/users/n3-charts/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/n3-charts/subscriptions","organizations_url":"https://api.github.com/users/n3-charts/orgs","repos_url":"https://api.github.com/users/n3-charts/repos","events_url":"https://api.github.com/users/n3-charts/events{/privacy}","received_events_url":"https://api.github.com/users/n3-charts/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/n3-charts/line-chart","description":"Awesome charts for AngularJS.","fork":false,"url":"https://api.github.com/repos/n3-charts/line-chart","forks_url":"https://api.github.com/repos/n3-charts/line-chart/forks","keys_url":"https://api.github.com/repos/n3-charts/line-chart/keys{/key_id}","collaborators_url":"https://api.github.com/repos/n3-charts/line-chart/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/n3-charts/line-chart/teams","hooks_url":"https://api.github.com/repos/n3-charts/line-chart/hooks","issue_events_url":"https://api.github.com/repos/n3-charts/line-chart/issues/events{/number}","events_url":"https://api.github.com/repos/n3-charts/line-chart/events","assignees_url":"https://api.github.com/repos/n3-charts/line-chart/assignees{/user}","branches_url":"https://api.github.com/repos/n3-charts/line-chart/branches{/branch}","tags_url":"https://api.github.com/repos/n3-charts/line-chart/tags","blobs_url":"https://api.github.com/repos/n3-charts/line-chart/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/n3-charts/line-chart/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/n3-charts/line-chart/git/refs{/sha}","trees_url":"https://api.github.com/repos/n3-charts/line-chart/git/trees{/sha}","statuses_url":"https://api.github.com/repos/n3-charts/line-chart/statuses/{sha}","languages_url":"https://api.github.com/repos/n3-charts/line-chart/languages","stargazers_url":"https://api.github.com/repos/n3-charts/line-chart/stargazers","contributors_url":"https://api.github.com/repos/n3-charts/line-chart/contributors","subscribers_url":"https://api.github.com/repos/n3-charts/line-chart/subscribers","subscription_url":"https://api.github.com/repos/n3-charts/line-chart/subscription","commits_url":"https://api.github.com/repos/n3-charts/line-chart/commits{/sha}","git_commits_url":"https://api.github.com/repos/n3-charts/line-chart/git/commits{/sha}","comments_url":"https://api.github.com/repos/n3-charts/line-chart/comments{/number}","issue_comment_url":"https://api.github.com/repos/n3-charts/line-chart/issues/comments{/number}","contents_url":"https://api.github.com/repos/n3-charts/line-chart/contents/{+path}","compare_url":"https://api.github.com/repos/n3-charts/line-chart/compare/{base}...{head}","merges_url":"https://api.github.com/repos/n3-charts/line-chart/merges","archive_url":"https://api.github.com/repos/n3-charts/line-chart/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/n3-charts/line-chart/downloads","issues_url":"https://api.github.com/repos/n3-charts/line-chart/issues{/number}","pulls_url":"https://api.github.com/repos/n3-charts/line-chart/pulls{/number}","milestones_url":"https://api.github.com/repos/n3-charts/line-chart/milestones{/number}","notifications_url":"https://api.github.com/repos/n3-charts/line-chart/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/n3-charts/line-chart/labels{/name}","releases_url":"https://api.github.com/repos/n3-charts/line-chart/releases{/id}","created_at":"2013-05-05T19:01:04Z","updated_at":"2015-05-29T08:46:23Z","pushed_at":"2015-05-30T16:37:21Z","git_url":"git://github.com/n3-charts/line-chart.git","ssh_url":"git@github.com:n3-charts/line-chart.git","clone_url":"https://github.com/n3-charts/line-chart.git","svn_url":"https://github.com/n3-charts/line-chart","homepage":"http://n3-charts.github.io/line-chart/","size":14956,"stargazers_count":891,"watchers_count":891,"language":"CoffeeScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":123,"mirror_url":null,"open_issues_count":28,"forks":123,"open_issues":28,"watchers":891,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/n3-charts/line-chart/pulls/243"},"html":{"href":"https://github.com/n3-charts/line-chart/pull/243"},"issue":{"href":"https://api.github.com/repos/n3-charts/line-chart/issues/243"},"comments":{"href":"https://api.github.com/repos/n3-charts/line-chart/issues/243/comments"},"review_comments":{"href":"https://api.github.com/repos/n3-charts/line-chart/pulls/243/comments"},"review_comment":{"href":"https://api.github.com/repos/n3-charts/line-chart/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/n3-charts/line-chart/pulls/243/commits"},"statuses":{"href":"https://api.github.com/repos/n3-charts/line-chart/statuses/eb4acc58a8b6463affdb8fb3d4c3d2f6b561b997"}}}}