{"action":"created","issue":{"url":"https://api.github.com/repos/Urigo/angular-meteor/issues/955","labels_url":"https://api.github.com/repos/Urigo/angular-meteor/issues/955/labels{/name}","comments_url":"https://api.github.com/repos/Urigo/angular-meteor/issues/955/comments","events_url":"https://api.github.com/repos/Urigo/angular-meteor/issues/955/events","html_url":"https://github.com/Urigo/angular-meteor/issues/955","id":122111248,"number":955,"title":"How to handle reactive properties - discussion","user":{"login":"Urigo","id":1297448,"avatar_url":"https://avatars.githubusercontent.com/u/1297448?v=3","gravatar_id":"","url":"https://api.github.com/users/Urigo","html_url":"https://github.com/Urigo","followers_url":"https://api.github.com/users/Urigo/followers","following_url":"https://api.github.com/users/Urigo/following{/other_user}","gists_url":"https://api.github.com/users/Urigo/gists{/gist_id}","starred_url":"https://api.github.com/users/Urigo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Urigo/subscriptions","organizations_url":"https://api.github.com/users/Urigo/orgs","repos_url":"https://api.github.com/users/Urigo/repos","events_url":"https://api.github.com/users/Urigo/events{/privacy}","received_events_url":"https://api.github.com/users/Urigo/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/Urigo/angular-meteor/labels/help%20wanted","name":"help wanted","color":"159818"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":13,"created_at":"2015-12-14T19:20:42Z","updated_at":"2015-12-18T06:01:11Z","closed_at":null,"body":"Hello, \r\nIn version 1.3 we introduced the `helpers` syntax which can take 2 types of values:\r\n\r\n1. Functions - The function return value will be binded to scope and re-run reactively \r\n2. Primitives - A primitive we be binded to scope and will trigger a reactive change every time it will change (reactive var). It's purpose is the same as [getReactively](http://www.angular-meteor.com/api/1.3.0/getReactively) but it is implemented differently.\r\n\r\nThere is one issue with the current solution where when the primitive will change in a nested value, it won't fire a reactive change event (https://github.com/Urigo/angular-meteor/issues/939)\r\n\r\nBut that issue made me think about the current API and if it is the best solution.\r\n\r\nHere are a few options for that API and I would love to hear your thoughts about that:\r\n\r\n1. Stay with the current solution, meaning that `helpers` understands the difference on the value that is sent to it and according to that defines the value to be a reactive property (and fix the issue)\r\n2.  Separate. `helpers` to be just for functions and `reactiveProps` would be for primitives.\r\n3. Continue using `getReactively` like we do today meaning, we define regular Angular variable as usually and when we want to use them reactively we surround them with a `getReactively` function.  we can also rename it to `track` or something nicer\r\n4. Create a new way to declare reactive objects in meteor. Since reactiveVar only allows editing the whole object, that would mean we won't have reactivity when we change a property of that object. Instead we can create a new way to declare a reactive object in the following way:\r\n```js\r\n$scope.myVar = ReactiveVar.from({\r\n\ta : 1,\r\n\tb : {\r\n\t\tc : ReactiveVar.from(4)\r\n\t}\r\n});\r\n```\r\nThis should allow us to say explicitly which properties we want to be reactive in the reactive var that we are creating. That way we also won't need to call any helper function on the scope, just declare a new property, or a variable if we are not using scope at all.\r\n5. Other options you might think of\r\n\r\nThere is also an important mention about the implementation.\r\nIn the `helpers`/`reactiveProps` solutions we need to watch the nested values but also give you the option not to do a nested watch as sometimes it can be bad for performance.\r\nWith `getReactively` we use Angular's watch with the same Angular API - the default is a regular Angular $watch but we can send a second parameter as a flag that if is `true` it will watch the value in a deep way.\r\nIf you think that `helpers` or `reactiveProps` are the way to go, please also suggest how a deep would look in this API.\r\nWe will add the new API in 1.3.1 but leave the current implementation (with a nested fix) till 1.4 so we won't introduce more breaking changes.\r\nWaiting to hear your suggestions\r\n"},"comment":{"url":"https://api.github.com/repos/Urigo/angular-meteor/issues/comments/165680869","html_url":"https://github.com/Urigo/angular-meteor/issues/955#issuecomment-165680869","issue_url":"https://api.github.com/repos/Urigo/angular-meteor/issues/955","id":165680869,"user":{"login":"mattiLeBlanc","id":5285035,"avatar_url":"https://avatars.githubusercontent.com/u/5285035?v=3","gravatar_id":"","url":"https://api.github.com/users/mattiLeBlanc","html_url":"https://github.com/mattiLeBlanc","followers_url":"https://api.github.com/users/mattiLeBlanc/followers","following_url":"https://api.github.com/users/mattiLeBlanc/following{/other_user}","gists_url":"https://api.github.com/users/mattiLeBlanc/gists{/gist_id}","starred_url":"https://api.github.com/users/mattiLeBlanc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mattiLeBlanc/subscriptions","organizations_url":"https://api.github.com/users/mattiLeBlanc/orgs","repos_url":"https://api.github.com/users/mattiLeBlanc/repos","events_url":"https://api.github.com/users/mattiLeBlanc/events{/privacy}","received_events_url":"https://api.github.com/users/mattiLeBlanc/received_events","type":"User","site_admin":false},"created_at":"2015-12-18T06:01:11Z","updated_at":"2015-12-18T06:01:11Z","body":"Quesiton: how the Reactivity going to work with a model change?\r\nFor example, having a datepicker\r\n```\r\nmd-datepicker(name=\"dateField\" ng-model=\"vm.filter.fromDate\" md-placeholder=\"Enter date\" required md-min-date=\"minDate\" md-max-date=\"\r\n```\r\nWhen the user selects a date, now I get a notification of that by using autorun:\r\n```\r\n   $scope.$meteorAutorun ->\r\n      console.log($scope.getReactively( 'vm.filter.fromDate') )\r\n```\r\n\r\nIs this going to be 'bad practice'? A helper doesn't seem to make sense because a helper (in Blaze) is mainly there to print stuff in templates, right?\r\nSo a model update doesn't fit in that category.\r\nStill it would be nice if any update on the model would be monitored too.\r\nOr should we always us the getReactively function within an autorun?"}}