{"action":"created","issue":{"url":"https://api.github.com/repos/techfort/LokiJS/issues/94","labels_url":"https://api.github.com/repos/techfort/LokiJS/issues/94/labels{/name}","comments_url":"https://api.github.com/repos/techfort/LokiJS/issues/94/comments","events_url":"https://api.github.com/repos/techfort/LokiJS/issues/94/events","html_url":"https://github.com/techfort/LokiJS/issues/94","id":60604054,"number":94,"title":"Question about changes API","user":{"login":"c0bra","id":105007,"avatar_url":"https://avatars.githubusercontent.com/u/105007?v=3","gravatar_id":"","url":"https://api.github.com/users/c0bra","html_url":"https://github.com/c0bra","followers_url":"https://api.github.com/users/c0bra/followers","following_url":"https://api.github.com/users/c0bra/following{/other_user}","gists_url":"https://api.github.com/users/c0bra/gists{/gist_id}","starred_url":"https://api.github.com/users/c0bra/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/c0bra/subscriptions","organizations_url":"https://api.github.com/users/c0bra/orgs","repos_url":"https://api.github.com/users/c0bra/repos","events_url":"https://api.github.com/users/c0bra/events{/privacy}","received_events_url":"https://api.github.com/users/c0bra/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-03-11T03:16:08Z","updated_at":"2015-03-11T11:50:36Z","closed_at":null,"body":"Is there a chance that a change could occur in-between serializeChanges and clearChanges?\r\n\r\nIf so could they both take a Date argument to avoid this? Or maybe I'm missing something?"},"comment":{"url":"https://api.github.com/repos/techfort/LokiJS/issues/comments/78248942","html_url":"https://github.com/techfort/LokiJS/issues/94#issuecomment-78248942","issue_url":"https://api.github.com/repos/techfort/LokiJS/issues/94","id":78248942,"user":{"login":"techfort","id":4130173,"avatar_url":"https://avatars.githubusercontent.com/u/4130173?v=3","gravatar_id":"","url":"https://api.github.com/users/techfort","html_url":"https://github.com/techfort","followers_url":"https://api.github.com/users/techfort/followers","following_url":"https://api.github.com/users/techfort/following{/other_user}","gists_url":"https://api.github.com/users/techfort/gists{/gist_id}","starred_url":"https://api.github.com/users/techfort/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/techfort/subscriptions","organizations_url":"https://api.github.com/users/techfort/orgs","repos_url":"https://api.github.com/users/techfort/repos","events_url":"https://api.github.com/users/techfort/events{/privacy}","received_events_url":"https://api.github.com/users/techfort/received_events","type":"User","site_admin":false},"created_at":"2015-03-11T11:50:36Z","updated_at":"2015-03-11T11:50:36Z","body":"Yep, confirming the synchronicity of those calls. Due to the\nsingle-threaded nature of javascript if you generate your changes and then\ncall clearChanges nothing will happen in between.\nclearChanges however is not called automatically (IIRC, i need to double\ncheck this), so you will need to make that call yourself. I remember not\nwanting to make the assumption that once generateChangesNotification is\ncompleted you would want to wipe all the changes up to that point: it is a\nvery likely usage, but - for example - if you're transmitting that data\nover a network I'd wait for a successful response before wiping the\nchanges, and you would not want to lose all the changes if the network\nconnection failed (then you'd find yourself with all the local changes lost\nand your remote source not having received the changes up to that point).\n\nIf this is the kind of usage you're making of the changes api then yes - it\nis possible a change will have occurred between the time you issue your\nnetwork request and the time you got a response. In that case you're going\nto have to come up with an ad-hoc mechanism to manage that.\n\nThis case does bring up the issue of a transaction \"lock\" though. It would\nprobably be a nice feature to prevent \"leaking\" changes. If you have any\nmore details on the use case we can examine implementing a particular\nsafeguard / lock to avoid inconsistencies.\n\n\nOn Wed, Mar 11, 2015 at 11:25 AM, obeliskos <notifications@github.com>\nwrote:\n\n> This is mostly Techfort's area of expertise, so hopefully he will chime\n> in.\n>\n> Looking at the code it seems both calls are synchronous... do you have\n> pending insert/update/delete calls into loki which are async on your end?\n>\n> —\n> Reply to this email directly or view it on GitHub\n> <https://github.com/techfort/LokiJS/issues/94#issuecomment-78246048>.\n>\n"}}