{"action":"created","issue":{"url":"https://api.github.com/repos/phetsims/rutherford-scattering/issues/19","repository_url":"https://api.github.com/repos/phetsims/rutherford-scattering","labels_url":"https://api.github.com/repos/phetsims/rutherford-scattering/issues/19/labels{/name}","comments_url":"https://api.github.com/repos/phetsims/rutherford-scattering/issues/19/comments","events_url":"https://api.github.com/repos/phetsims/rutherford-scattering/issues/19/events","html_url":"https://github.com/phetsims/rutherford-scattering/issues/19","id":135485774,"number":19,"title":"Use ObservableArray for Particles and added/removed events in AtomModel.js","user":{"login":"samreid","id":679486,"avatar_url":"https://avatars.githubusercontent.com/u/679486?v=3","gravatar_id":"","url":"https://api.github.com/users/samreid","html_url":"https://github.com/samreid","followers_url":"https://api.github.com/users/samreid/followers","following_url":"https://api.github.com/users/samreid/following{/other_user}","gists_url":"https://api.github.com/users/samreid/gists{/gist_id}","starred_url":"https://api.github.com/users/samreid/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/samreid/subscriptions","organizations_url":"https://api.github.com/users/samreid/orgs","repos_url":"https://api.github.com/users/samreid/repos","events_url":"https://api.github.com/users/samreid/events{/privacy}","received_events_url":"https://api.github.com/users/samreid/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/phetsims/rutherford-scattering/labels/dev:code-review","name":"dev:code-review","color":"104E8B"}],"state":"closed","locked":false,"assignee":{"login":"samreid","id":679486,"avatar_url":"https://avatars.githubusercontent.com/u/679486?v=3","gravatar_id":"","url":"https://api.github.com/users/samreid","html_url":"https://github.com/samreid","followers_url":"https://api.github.com/users/samreid/followers","following_url":"https://api.github.com/users/samreid/following{/other_user}","gists_url":"https://api.github.com/users/samreid/gists{/gist_id}","starred_url":"https://api.github.com/users/samreid/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/samreid/subscriptions","organizations_url":"https://api.github.com/users/samreid/orgs","repos_url":"https://api.github.com/users/samreid/repos","events_url":"https://api.github.com/users/samreid/events{/privacy}","received_events_url":"https://api.github.com/users/samreid/received_events","type":"User","site_admin":false},"milestone":null,"comments":3,"created_at":"2016-02-22T17:32:52Z","updated_at":"2016-02-25T17:32:10Z","closed_at":"2016-02-25T17:32:10Z","body":"At the beginning of AtomModel's constructor, there are these declarations:\r\n\r\n```js\r\n    this.particles = [];  // all active alpha particle models\r\n    this.particleAddCallbacks = []; // @protected called when a alpha particle is added\r\n    this.particleRemoveCallbacks = []; // @protected called when a alpha particle is removed\r\n```\r\n\r\nThen `addParticle` is declared like so:\r\n\r\n```js\r\n    /**\r\n     * @param {AlphaParticleModel} alphaParticle\r\n     * @public\r\n     */\r\n    addParticle: function( alphaParticle ) {\r\n\r\n      this.particles.push( alphaParticle );\r\n\r\n      // call registered callbacks\r\n      var callbacks = this.particleAddCallbacks.slice( 0 );\r\n      for ( var i = 0; i < callbacks.length; i++ ) {\r\n        callbacks[ i ]( alphaParticle );\r\n      }\r\n    },\r\n```\r\n\r\nA simpler alternative would be to use Axon for sending the events.\r\n\r\n`AXON/ObservableArray` provides an array with built-in functions for sending notifications when items are added or removed.  This is probably the best approach for this case, but if there are other constraints that require you to use a separate array here, then you could alternatively use `AXON/Emitter` for sending the events.  I'd suggest to try ObservableArray first and see if that will work."},"comment":{"url":"https://api.github.com/repos/phetsims/rutherford-scattering/issues/comments/188893236","html_url":"https://github.com/phetsims/rutherford-scattering/issues/19#issuecomment-188893236","issue_url":"https://api.github.com/repos/phetsims/rutherford-scattering/issues/19","id":188893236,"user":{"login":"samreid","id":679486,"avatar_url":"https://avatars.githubusercontent.com/u/679486?v=3","gravatar_id":"","url":"https://api.github.com/users/samreid","html_url":"https://github.com/samreid","followers_url":"https://api.github.com/users/samreid/followers","following_url":"https://api.github.com/users/samreid/following{/other_user}","gists_url":"https://api.github.com/users/samreid/gists{/gist_id}","starred_url":"https://api.github.com/users/samreid/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/samreid/subscriptions","organizations_url":"https://api.github.com/users/samreid/orgs","repos_url":"https://api.github.com/users/samreid/repos","events_url":"https://api.github.com/users/samreid/events{/privacy}","received_events_url":"https://api.github.com/users/samreid/received_events","type":"User","site_admin":false},"created_at":"2016-02-25T17:32:10Z","updated_at":"2016-02-25T17:32:10Z","body":"Thanks @schmitzware, closing."}}