{"action":"created","issue":{"url":"https://api.github.com/repos/canjs/can-simple-observable/issues/33","repository_url":"https://api.github.com/repos/canjs/can-simple-observable","labels_url":"https://api.github.com/repos/canjs/can-simple-observable/issues/33/labels{/name}","comments_url":"https://api.github.com/repos/canjs/can-simple-observable/issues/33/comments","events_url":"https://api.github.com/repos/canjs/can-simple-observable/issues/33/events","html_url":"https://github.com/canjs/can-simple-observable/issues/33","id":353540637,"node_id":"MDU6SXNzdWUzNTM1NDA2Mzc=","number":33,"title":"Set value on SetterObservable when it's set","user":{"login":"RyanMilligan","id":8312669,"node_id":"MDQ6VXNlcjgzMTI2Njk=","avatar_url":"https://avatars1.githubusercontent.com/u/8312669?v=4","gravatar_id":"","url":"https://api.github.com/users/RyanMilligan","html_url":"https://github.com/RyanMilligan","followers_url":"https://api.github.com/users/RyanMilligan/followers","following_url":"https://api.github.com/users/RyanMilligan/following{/other_user}","gists_url":"https://api.github.com/users/RyanMilligan/gists{/gist_id}","starred_url":"https://api.github.com/users/RyanMilligan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RyanMilligan/subscriptions","organizations_url":"https://api.github.com/users/RyanMilligan/orgs","repos_url":"https://api.github.com/users/RyanMilligan/repos","events_url":"https://api.github.com/users/RyanMilligan/events{/privacy}","received_events_url":"https://api.github.com/users/RyanMilligan/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":{"login":"justinbmeyer","id":78602,"node_id":"MDQ6VXNlcjc4NjAy","avatar_url":"https://avatars0.githubusercontent.com/u/78602?v=4","gravatar_id":"","url":"https://api.github.com/users/justinbmeyer","html_url":"https://github.com/justinbmeyer","followers_url":"https://api.github.com/users/justinbmeyer/followers","following_url":"https://api.github.com/users/justinbmeyer/following{/other_user}","gists_url":"https://api.github.com/users/justinbmeyer/gists{/gist_id}","starred_url":"https://api.github.com/users/justinbmeyer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/justinbmeyer/subscriptions","organizations_url":"https://api.github.com/users/justinbmeyer/orgs","repos_url":"https://api.github.com/users/justinbmeyer/repos","events_url":"https://api.github.com/users/justinbmeyer/events{/privacy}","received_events_url":"https://api.github.com/users/justinbmeyer/received_events","type":"User","site_admin":false},"assignees":[{"login":"justinbmeyer","id":78602,"node_id":"MDQ6VXNlcjc4NjAy","avatar_url":"https://avatars0.githubusercontent.com/u/78602?v=4","gravatar_id":"","url":"https://api.github.com/users/justinbmeyer","html_url":"https://github.com/justinbmeyer","followers_url":"https://api.github.com/users/justinbmeyer/followers","following_url":"https://api.github.com/users/justinbmeyer/following{/other_user}","gists_url":"https://api.github.com/users/justinbmeyer/gists{/gist_id}","starred_url":"https://api.github.com/users/justinbmeyer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/justinbmeyer/subscriptions","organizations_url":"https://api.github.com/users/justinbmeyer/orgs","repos_url":"https://api.github.com/users/justinbmeyer/repos","events_url":"https://api.github.com/users/justinbmeyer/events{/privacy}","received_events_url":"https://api.github.com/users/justinbmeyer/received_events","type":"User","site_admin":false}],"milestone":null,"comments":8,"created_at":"2018-08-23T20:26:46Z","updated_at":"2018-08-29T20:52:52Z","closed_at":null,"author_association":"NONE","body":"In migrating one of our applications to Can 4, I've encountered what appears to be a pretty low-level problem in SetterObservable: specifically, when you call its setter, it never actually updates its `value` property. I assume this is because it's expected that the `observation` handler will be used to retrieve the value, but when can-bind calls the setter in [updateValue](https://github.com/canjs/can-bind/blob/37e4bb6e6a6f5ab4d31f994b302681a53481f64c/can-bind.js#L398) (`args.observable` will be a `SetterObservable` in the case where value that's changing is bound to a converter), it then immediately calls the getter on the same observable.\r\n\r\nThis would be fine, except that because `bound` is true, the getter (implemented in [get-set.js](https://github.com/canjs/can-simple-observable/blob/2a1e16d3794afab8d41d8eb060477136b93e4c94/settable/settable.js#L120)) skips using the `observation` function and returns `this.value` directly, which returns whatever the parent value was at the time the binding was set up.\r\n\r\nThis has a few negative side effects when using two-way binding through a converter:\r\n1) A confusing semaphore warning is written out to the console because the `updateValue` function referenced above will cycle multiple times trying to get the parent and child values to agree (even though they already do; it's simply looking at an old snapshot of the parent value to do the comparison), which involves overwriting the child value with the original value of the parent, which will basically always be wrong\r\n2) The issue that led to me debugging this problem was that my child value was being set first to the expected value, then to whatever the parent value was when the UI was created, then back to the correct value, which was causing unexpected behavior in my application.\r\n\r\nI've created a jsbin that reproduces my binding scenario and demonstrates the warning: https://jsbin.com/kevolovonu/4/edit?html,js,console,output\r\n\r\nI was unable to get it to reproduce the multiple sets, but I think the warning is probably sufficient to demonstrate that there's a problem here. The solution I found was to add `this.value = ` to the beginning of [SetterObservable.prototype.set](https://github.com/canjs/can-simple-observable/blob/2a1e16d3794afab8d41d8eb060477136b93e4c94/setter/setter.js#L36)."},"comment":{"url":"https://api.github.com/repos/canjs/can-simple-observable/issues/comments/417101896","html_url":"https://github.com/canjs/can-simple-observable/issues/33#issuecomment-417101896","issue_url":"https://api.github.com/repos/canjs/can-simple-observable/issues/33","id":417101896,"node_id":"MDEyOklzc3VlQ29tbWVudDQxNzEwMTg5Ng==","user":{"login":"justinbmeyer","id":78602,"node_id":"MDQ6VXNlcjc4NjAy","avatar_url":"https://avatars0.githubusercontent.com/u/78602?v=4","gravatar_id":"","url":"https://api.github.com/users/justinbmeyer","html_url":"https://github.com/justinbmeyer","followers_url":"https://api.github.com/users/justinbmeyer/followers","following_url":"https://api.github.com/users/justinbmeyer/following{/other_user}","gists_url":"https://api.github.com/users/justinbmeyer/gists{/gist_id}","starred_url":"https://api.github.com/users/justinbmeyer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/justinbmeyer/subscriptions","organizations_url":"https://api.github.com/users/justinbmeyer/orgs","repos_url":"https://api.github.com/users/justinbmeyer/repos","events_url":"https://api.github.com/users/justinbmeyer/events{/privacy}","received_events_url":"https://api.github.com/users/justinbmeyer/received_events","type":"User","site_admin":false},"created_at":"2018-08-29T20:52:52Z","updated_at":"2018-08-29T20:52:52Z","author_association":"CONTRIBUTOR","body":"In this case which is identical to your situation: https://justinbmeyer.jsbin.com/rinipuk/1/edit?js,output\r\n\r\nAfter changing the input to 1, it logs:\r\n\r\n```\r\nsubProp.get  1\r\nmyConverter.set  1\r\nfoo.set  1\r\nsubProp.get  DefineMap\r\nrunner-4.1.4.min.js:1 can-bind updateValue: attempting to update child AttributeObservable<input.value> to new value: NaN\r\n…but the child semaphore is at 1 and the parent semaphore is at 1. The number of allowed updates is 1.\r\nThe child value will remain unchanged; it’s currently: \"1\"\r\n```\r\n\r\n"}}
{"actor":{"display_login":"justinbmeyer"}}