{"action":"created","issue":{"url":"https://api.github.com/repos/leeoniya/domvm/issues/68","repository_url":"https://api.github.com/repos/leeoniya/domvm","labels_url":"https://api.github.com/repos/leeoniya/domvm/issues/68/labels{/name}","comments_url":"https://api.github.com/repos/leeoniya/domvm/issues/68/comments","events_url":"https://api.github.com/repos/leeoniya/domvm/issues/68/events","html_url":"https://github.com/leeoniya/domvm/issues/68","id":153353653,"number":68,"title":"Decoupled model and view where model has properties which trigger redraws on the view","user":{"login":"lawrence-dol","id":8662551,"avatar_url":"https://avatars.githubusercontent.com/u/8662551?v=3","gravatar_id":"","url":"https://api.github.com/users/lawrence-dol","html_url":"https://github.com/lawrence-dol","followers_url":"https://api.github.com/users/lawrence-dol/followers","following_url":"https://api.github.com/users/lawrence-dol/following{/other_user}","gists_url":"https://api.github.com/users/lawrence-dol/gists{/gist_id}","starred_url":"https://api.github.com/users/lawrence-dol/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lawrence-dol/subscriptions","organizations_url":"https://api.github.com/users/lawrence-dol/orgs","repos_url":"https://api.github.com/users/lawrence-dol/repos","events_url":"https://api.github.com/users/lawrence-dol/events{/privacy}","received_events_url":"https://api.github.com/users/lawrence-dol/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":7,"created_at":"2016-05-06T00:15:35Z","updated_at":"2016-05-06T01:20:01Z","closed_at":null,"body":"I've been dancing around this issue since #60, but it's getting progressively more difficult. How would you recommend that a decoupled data-model which needs to trigger redraws on the `vm` that uses it be constructed?\r\n\r\nThe essential problem being that the properties of the model can't be created until the `vm` reference is available, but the model wants to be created before the view and injected into it.\r\n\r\n````\r\nvar model=new DataModel();\r\nvar view =domvm.view(new DataView(model)); // or (new DataView(),model)\r\n````\r\n\r\nBut DataModel needs the DataView view-model to do the moral equivalent of:\r\n\r\n````\r\nvar w=domvm.watch(function() { vm.redraw(); });\r\n...\r\nexported.someProp=w.prop(\"default\");\r\n````\r\n\r\nSo the model can't be injected into the view, and the view can't be injected into the model. I can't see a clean way to do this."},"comment":{"url":"https://api.github.com/repos/leeoniya/domvm/issues/comments/217323959","html_url":"https://github.com/leeoniya/domvm/issues/68#issuecomment-217323959","issue_url":"https://api.github.com/repos/leeoniya/domvm/issues/68","id":217323959,"user":{"login":"lawrence-dol","id":8662551,"avatar_url":"https://avatars.githubusercontent.com/u/8662551?v=3","gravatar_id":"","url":"https://api.github.com/users/lawrence-dol","html_url":"https://github.com/lawrence-dol","followers_url":"https://api.github.com/users/lawrence-dol/followers","following_url":"https://api.github.com/users/lawrence-dol/following{/other_user}","gists_url":"https://api.github.com/users/lawrence-dol/gists{/gist_id}","starred_url":"https://api.github.com/users/lawrence-dol/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lawrence-dol/subscriptions","organizations_url":"https://api.github.com/users/lawrence-dol/orgs","repos_url":"https://api.github.com/users/lawrence-dol/repos","events_url":"https://api.github.com/users/lawrence-dol/events{/privacy}","received_events_url":"https://api.github.com/users/lawrence-dol/received_events","type":"User","site_admin":false},"created_at":"2016-05-06T01:20:01Z","updated_at":"2016-05-06T01:20:01Z","body":"Currently I have two sub views:\r\n\r\n    function AppView(vm) {\r\n        var sub1=new BodyView(new BodyModel(vm));\r\n        var sub2=new StatusView(new StatusModel(vm));\r\n        return function() {\r\n            [\"div\",[\r\n                sub1,\r\n                sub2,\r\n            ]]\r\n        }\r\n    }\r\n\r\nWhenever the status model is change, it need only update the StatusView, but it's currently updating the AppView because there's no other reference to a vm available."}}