{"action":"opened","issue":{"url":"https://api.github.com/repos/dojo/shim/issues/39","repository_url":"https://api.github.com/repos/dojo/shim","labels_url":"https://api.github.com/repos/dojo/shim/issues/39/labels{/name}","comments_url":"https://api.github.com/repos/dojo/shim/issues/39/comments","events_url":"https://api.github.com/repos/dojo/shim/issues/39/events","html_url":"https://github.com/dojo/shim/issues/39","id":183036374,"number":39,"title":"Behaviour when setting `.observeState()`","user":{"login":"kitsonk","id":1282577,"avatar_url":"https://avatars.githubusercontent.com/u/1282577?v=3","gravatar_id":"","url":"https://api.github.com/users/kitsonk","html_url":"https://github.com/kitsonk","followers_url":"https://api.github.com/users/kitsonk/followers","following_url":"https://api.github.com/users/kitsonk/following{/other_user}","gists_url":"https://api.github.com/users/kitsonk/gists{/gist_id}","starred_url":"https://api.github.com/users/kitsonk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kitsonk/subscriptions","organizations_url":"https://api.github.com/users/kitsonk/orgs","repos_url":"https://api.github.com/users/kitsonk/repos","events_url":"https://api.github.com/users/kitsonk/events{/privacy}","received_events_url":"https://api.github.com/users/kitsonk/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/dojo/shim/labels/enhancement","name":"enhancement","color":"84b6eb"}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-10-14T12:21:43Z","updated_at":"2016-10-14T12:21:43Z","closed_at":null,"body":"Discussed between myself and @novemberborn in dojo/widgets#46 is that there is a potential *surprising* behaviour when setting `.observeState()` in that if there was already an existing unobserved state, this would not necessarily get reflected in the source observed state.\r\n\r\nFor example, if I did the following:\r\n\r\n```typescript\r\nimport createMemoryStore from 'dojo-stores/createMemoryStore';\r\nimport createStateful from 'dojo-compose/mixins/createStateful';\r\n\r\nconst store = createMemoryStore({\r\n    data: [ { id: 'foo', foo: 'bar' } ]\r\n});\r\n\r\nconst stateful = createStateful({\r\n    state: { bar: 2 }\r\n});\r\n\r\nstateful.observeState(store, 'foo');\r\n\r\nconsole.log(stateful.state); // { id: 'foo', foo: 'bar', bar: 2 }\r\nstore.get('foo')\r\n    .then((result) => console.log(result)); // { id: 'foo', foo: 'bar' }\r\n```\r\n\r\nIs this surprising?  What should be the correct behaviour?"}}
{"actor":{"display_login":"kitsonk"}}