{"action":"created","issue":{"url":"https://api.github.com/repos/realm/realm-java/issues/3048","repository_url":"https://api.github.com/repos/realm/realm-java","labels_url":"https://api.github.com/repos/realm/realm-java/issues/3048/labels{/name}","comments_url":"https://api.github.com/repos/realm/realm-java/issues/3048/comments","events_url":"https://api.github.com/repos/realm/realm-java/issues/3048/events","html_url":"https://github.com/realm/realm-java/issues/3048","id":161692943,"number":3048,"title":"Synchronous executeTransaction() with callbacks","user":{"login":"Zhuinden","id":11718392,"avatar_url":"https://avatars.githubusercontent.com/u/11718392?v=3","gravatar_id":"","url":"https://api.github.com/users/Zhuinden","html_url":"https://github.com/Zhuinden","followers_url":"https://api.github.com/users/Zhuinden/followers","following_url":"https://api.github.com/users/Zhuinden/following{/other_user}","gists_url":"https://api.github.com/users/Zhuinden/gists{/gist_id}","starred_url":"https://api.github.com/users/Zhuinden/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Zhuinden/subscriptions","organizations_url":"https://api.github.com/users/Zhuinden/orgs","repos_url":"https://api.github.com/users/Zhuinden/repos","events_url":"https://api.github.com/users/Zhuinden/events{/privacy}","received_events_url":"https://api.github.com/users/Zhuinden/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2016-06-22T14:09:05Z","updated_at":"2016-06-22T14:33:20Z","closed_at":null,"body":"> **Feature Request**: Just fill in the first two sections below.\r\n\r\n#### Goal\r\n\r\nReceive a callback on success/error when a *synchronous* transaction is successfully completed by Realm\r\n\r\n#### Expected Results\r\n\r\nSuccess/error is called\r\n\r\n#### Actual Results\r\n\r\nSince \r\n\r\n> RealmObject and RealmResults are always updated on the next event loop.\r\n\r\nyou would need to receive a looper event to know that your transaction has successfully been completed and the results are up to date. However, the API does not allow synchronous transactions with callbacks.\r\n\r\n```\r\nvoid\texecuteTransaction(Realm.Transaction transaction)\r\nExecutes a given transaction on the Realm.\r\n\r\nRealmAsyncTask\texecuteTransactionAsync(Realm.Transaction transaction)\r\nSimilar to executeTransaction(Transaction) but runs asynchronously on a worker thread.\r\n\r\nRealmAsyncTask\texecuteTransactionAsync(Realm.Transaction transaction, Realm.Transaction.OnError onError)\r\n\r\nSimilar to executeTransactionAsync(Transaction), but also accepts an OnError callback.\r\nRealmAsyncTask\texecuteTransactionAsync(Realm.Transaction transaction, Realm.Transaction.OnSuccess onSuccess)\r\nSimilar to executeTransactionAsync(Transaction), but also accepts an OnSuccess callback.\r\n\r\nRealmAsyncTask\texecuteTransactionAsync(Realm.Transaction transaction, Realm.Transaction.OnSuccess onSuccess, Realm.Transaction.OnError onError)\r\nSimilar to executeTransactionAsync(Transaction), but also accepts an OnSuccess and OnError callbacks.\r\n```\r\n\r\nWhich means there is no such thing as\r\n\r\n``` java\r\n    void\texecuteTransaction(Realm.Transaction transaction, Realm.Transaction.OnSuccess onSuccess)\r\n    void\texecuteTransaction(Realm.Transaction transaction, Realm.Transaction.OnError onError)\r\n    void\texecuteTransaction(Realm.Transaction transaction, Realm.Transaction.OnSuccess onSuccess, Realm.Transaction.OnError onError)\r\n```\r\n\r\nBut via change listeners, you can't be certain what transaction's success you're listening to, just that you've modified the underlying table on some thread.\r\n\r\nOf course, maybe writing to the Realm synchronously on the UI thread is strongly discouraged.\r\n\r\nRealm version(s): 1.0.1"},"comment":{"url":"https://api.github.com/repos/realm/realm-java/issues/comments/227763283","html_url":"https://github.com/realm/realm-java/issues/3048#issuecomment-227763283","issue_url":"https://api.github.com/repos/realm/realm-java/issues/3048","id":227763283,"user":{"login":"Zhuinden","id":11718392,"avatar_url":"https://avatars.githubusercontent.com/u/11718392?v=3","gravatar_id":"","url":"https://api.github.com/users/Zhuinden","html_url":"https://github.com/Zhuinden","followers_url":"https://api.github.com/users/Zhuinden/followers","following_url":"https://api.github.com/users/Zhuinden/following{/other_user}","gists_url":"https://api.github.com/users/Zhuinden/gists{/gist_id}","starred_url":"https://api.github.com/users/Zhuinden/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Zhuinden/subscriptions","organizations_url":"https://api.github.com/users/Zhuinden/orgs","repos_url":"https://api.github.com/users/Zhuinden/repos","events_url":"https://api.github.com/users/Zhuinden/events{/privacy}","received_events_url":"https://api.github.com/users/Zhuinden/received_events","type":"User","site_admin":false},"created_at":"2016-06-22T14:33:20Z","updated_at":"2016-06-22T14:33:20Z","body":"I do wonder if this can easily be resolved just by adding `handler.post(new Runnable() {...});` by the user after the `executeTransaction()` call and this question is solved quite easily."}}
{"actor":{"display_login":"Zhuinden"}}