{"action":"created","issue":{"url":"https://api.github.com/repos/knockout/knockout/issues/1637","labels_url":"https://api.github.com/repos/knockout/knockout/issues/1637/labels{/name}","comments_url":"https://api.github.com/repos/knockout/knockout/issues/1637/comments","events_url":"https://api.github.com/repos/knockout/knockout/issues/1637/events","html_url":"https://github.com/knockout/knockout/issues/1637","id":50103116,"number":1637,"title":"New feature: communication to components","user":{"login":"conficient","id":454494,"avatar_url":"https://avatars.githubusercontent.com/u/454494?v=3","gravatar_id":"","url":"https://api.github.com/users/conficient","html_url":"https://github.com/conficient","followers_url":"https://api.github.com/users/conficient/followers","following_url":"https://api.github.com/users/conficient/following{/other_user}","gists_url":"https://api.github.com/users/conficient/gists{/gist_id}","starred_url":"https://api.github.com/users/conficient/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/conficient/subscriptions","organizations_url":"https://api.github.com/users/conficient/orgs","repos_url":"https://api.github.com/users/conficient/repos","events_url":"https://api.github.com/users/conficient/events{/privacy}","received_events_url":"https://api.github.com/users/conficient/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/knockout/knockout/labels/affected:%20average","name":"affected: average","color":"80c880"},{"url":"https://api.github.com/repos/knockout/knockout/labels/api","name":"api","color":"000000"},{"url":"https://api.github.com/repos/knockout/knockout/labels/severity:%20major","name":"severity: major","color":"e14d51"},{"url":"https://api.github.com/repos/knockout/knockout/labels/type:%20feature","name":"type: feature","color":"207de5"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":34,"created_at":"2014-11-26T00:25:52Z","updated_at":"2015-12-13T14:30:59Z","closed_at":null,"body":"It is possible to get components to communicate with a host vm by passing a callback function to the component via the ```params```` binding, so the component is able talk to the host.\r\n\r\nThere is no feature to be able to invoke methods on the vm that I have seen. At present I pass observable values to the component and get the component vm to subscribe to these when it needs to know of events in the host.\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/knockout/knockout/issues/comments/164263276","html_url":"https://github.com/knockout/knockout/issues/1637#issuecomment-164263276","issue_url":"https://api.github.com/repos/knockout/knockout/issues/1637","id":164263276,"user":{"login":"jods4","id":3832820,"avatar_url":"https://avatars.githubusercontent.com/u/3832820?v=3","gravatar_id":"","url":"https://api.github.com/users/jods4","html_url":"https://github.com/jods4","followers_url":"https://api.github.com/users/jods4/followers","following_url":"https://api.github.com/users/jods4/following{/other_user}","gists_url":"https://api.github.com/users/jods4/gists{/gist_id}","starred_url":"https://api.github.com/users/jods4/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jods4/subscriptions","organizations_url":"https://api.github.com/users/jods4/orgs","repos_url":"https://api.github.com/users/jods4/repos","events_url":"https://api.github.com/users/jods4/events{/privacy}","received_events_url":"https://api.github.com/users/jods4/received_events","type":"User","site_admin":false},"created_at":"2015-12-13T14:30:59Z","updated_at":"2015-12-13T14:30:59Z","body":"I don't necessarily disagree with what you want, but that's a highly opinionated post @troyji.\r\n\r\n> Being a dynamic programming language, JavaScript employs a dynamic type system. [...] Let's stop fighting the language... [...] It is simply the JavaScript way.\r\n\r\nNot everyone works with JS and embraces its philosophy. I work on large systems using TypeScript and we absolutely _love_ the safety we get from the static type system. \r\nSo an argument about embracing the dynamic nature is actually a negative one in my book.\r\n\r\n> This is the most natural, straight-forward, intuitive way to communicate with the component.\r\n\r\nBroad statement. Moreover, none of this equates to \"good way\". I could say \"Stop using modules and namespaces. Everything should be a global variable as its the most natural, straight-forward, intuitive way to communicate with other code\". It works but I doubt you'll think it's a good idea.\r\n\r\nNow, to go into your direction. If we look at Aurelia, it has a `ref` binding command that does exactly this. It gives easy access in the VM to any DOM element or custom element (== KO components) ViewModel or custom attribute (== KO binding) ViewModel.\r\n\r\nFrom my experience with Aurelia, it comes in very handy when you need it. There are other (arguably better) solutions, but in simple situations it is OK and surely the most direct way.\r\n\r\nOf course abusing this creates tightly coupled code and views, less testable, and doesn't scale for  inter-components communications at large. But I still think it's worth having."}}