{"action":"created","issue":{"url":"https://api.github.com/repos/apollostack/apollo-client/issues/1025","repository_url":"https://api.github.com/repos/apollostack/apollo-client","labels_url":"https://api.github.com/repos/apollostack/apollo-client/issues/1025/labels{/name}","comments_url":"https://api.github.com/repos/apollostack/apollo-client/issues/1025/comments","events_url":"https://api.github.com/repos/apollostack/apollo-client/issues/1025/events","html_url":"https://github.com/apollostack/apollo-client/issues/1025","id":194569318,"number":1025,"title":"Reconnection strategy for Subscriptions","user":{"login":"sickboy","id":42661,"avatar_url":"https://avatars.githubusercontent.com/u/42661?v=3","gravatar_id":"","url":"https://api.github.com/users/sickboy","html_url":"https://github.com/sickboy","followers_url":"https://api.github.com/users/sickboy/followers","following_url":"https://api.github.com/users/sickboy/following{/other_user}","gists_url":"https://api.github.com/users/sickboy/gists{/gist_id}","starred_url":"https://api.github.com/users/sickboy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sickboy/subscriptions","organizations_url":"https://api.github.com/users/sickboy/orgs","repos_url":"https://api.github.com/users/sickboy/repos","events_url":"https://api.github.com/users/sickboy/events{/privacy}","received_events_url":"https://api.github.com/users/sickboy/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2016-12-09T11:04:00Z","updated_at":"2016-12-18T07:33:30Z","closed_at":null,"body":"Currently I fetch the status of an ongoing (long running background) operation, and subscribe to further notifications of changes.\r\nIf I loose the websocket connection and it comes back up, how would I bring my UI back up to speed?\r\nAnd how do I prevent out-of-order problems caused by events arriving sooner than my initial query?\r\nI think it would be great if the framework could assist in this, or at the least documentation that provides guidance.\r\n\r\nThoughts so far:\r\n1. Monitor the WebSocket connection client-side, once reconnected, fetch the current status again, just like when we started, and wait for notification of changes again\r\n  Downside: What if a new notification comes in sooner than my Query request is finished, my Query request might overwrite my current state with older information. Versioning the status/messages would be one way to address this but I think it's relatively error prone.\r\n2. Upon subscription on the server call a loader to get the \"initial value\", and publish it as the event. This would then automatically take care of reconnecting as well, but also suffers from the order problem - what if a new event comes in sooner than the querying finished\r\n\r\nsome additional thoughts:\r\n- To make approach 1. work, a \"reconnected\" event should be fired from the WebSockets Client, once a) the connection is up again, and b) the subscriptions have finished re-registering."},"comment":{"url":"https://api.github.com/repos/apollostack/apollo-client/issues/comments/267807841","html_url":"https://github.com/apollostack/apollo-client/issues/1025#issuecomment-267807841","issue_url":"https://api.github.com/repos/apollostack/apollo-client/issues/1025","id":267807841,"user":{"login":"thebigredgeek","id":2799276,"avatar_url":"https://avatars.githubusercontent.com/u/2799276?v=3","gravatar_id":"","url":"https://api.github.com/users/thebigredgeek","html_url":"https://github.com/thebigredgeek","followers_url":"https://api.github.com/users/thebigredgeek/followers","following_url":"https://api.github.com/users/thebigredgeek/following{/other_user}","gists_url":"https://api.github.com/users/thebigredgeek/gists{/gist_id}","starred_url":"https://api.github.com/users/thebigredgeek/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thebigredgeek/subscriptions","organizations_url":"https://api.github.com/users/thebigredgeek/orgs","repos_url":"https://api.github.com/users/thebigredgeek/repos","events_url":"https://api.github.com/users/thebigredgeek/events{/privacy}","received_events_url":"https://api.github.com/users/thebigredgeek/received_events","type":"User","site_admin":false},"created_at":"2016-12-18T07:33:30Z","updated_at":"2016-12-18T07:33:30Z","body":"I agree with @helfer .  You can keep a \"last heartbeat\" value in redux or whatever... and then upon reconnection you can refetch what you need based on that stamp.  Not perfect, but you could probably use a HOF to combine the subscription with a query so that query automatically runs with the \"last heartbeat\" value whenever the WS reconnects"}}
{"actor":{"display_login":"thebigredgeek"}}