{"action":"created","issue":{"url":"https://api.github.com/repos/pixelspark/rethink-swift/issues/8","repository_url":"https://api.github.com/repos/pixelspark/rethink-swift","labels_url":"https://api.github.com/repos/pixelspark/rethink-swift/issues/8/labels{/name}","comments_url":"https://api.github.com/repos/pixelspark/rethink-swift/issues/8/comments","events_url":"https://api.github.com/repos/pixelspark/rethink-swift/issues/8/events","html_url":"https://github.com/pixelspark/rethink-swift/issues/8","id":210853045,"number":8,"title":"Example code","user":{"login":"tsebastiani","id":15978528,"avatar_url":"https://avatars2.githubusercontent.com/u/15978528?v=4","gravatar_id":"","url":"https://api.github.com/users/tsebastiani","html_url":"https://github.com/tsebastiani","followers_url":"https://api.github.com/users/tsebastiani/followers","following_url":"https://api.github.com/users/tsebastiani/following{/other_user}","gists_url":"https://api.github.com/users/tsebastiani/gists{/gist_id}","starred_url":"https://api.github.com/users/tsebastiani/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tsebastiani/subscriptions","organizations_url":"https://api.github.com/users/tsebastiani/orgs","repos_url":"https://api.github.com/users/tsebastiani/repos","events_url":"https://api.github.com/users/tsebastiani/events{/privacy}","received_events_url":"https://api.github.com/users/tsebastiani/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2017-02-28T17:20:00Z","updated_at":"2017-08-10T09:07:58Z","closed_at":"2017-06-20T15:26:02Z","body":"Hi, \r\nI'm trying to implement a realtime application with rethinkdb and your driver.\r\nWhat I would like to achieve as first task Is to connect to the database and wait for changes in a table.\r\nActually the connection is fine but waiting for changes seems not to work.\r\nDo you have any example app that covers the basics of the driver?\r\nThis is my code: \r\n´´´\r\n        R.connect(URL(string: \"rethinkdb://192.168.250.96:28015\")!, user: \"user1\", password: \"user1\") { err, connection in\r\n            assert(err == nil, \"Connection error: \\(err)\")\r\n\r\n            R.db(\"test\").table(\"games\").indexWait().run(connection) { response in\r\n                assert(!response.isError, \"Failed to wait for index: \\(response)\")\r\n                R.db(\"test\").table(\"games\").changes().run(connection){ (response:ReResponse) in\r\n                    print (\"There's a change!!\")\r\n                }\r\n            }\r\n            \r\n            \r\n            \r\n        }\r\n´´´\r\nI would expect that any time I insert something in the table \"There's a change!!\" is printed in console , but that's not actually happening!\r\n\r\nThanks a lot."},"comment":{"url":"https://api.github.com/repos/pixelspark/rethink-swift/issues/comments/321495700","html_url":"https://github.com/pixelspark/rethink-swift/issues/8#issuecomment-321495700","issue_url":"https://api.github.com/repos/pixelspark/rethink-swift/issues/8","id":321495700,"user":{"login":"alextarrago","id":658279,"avatar_url":"https://avatars2.githubusercontent.com/u/658279?v=4","gravatar_id":"","url":"https://api.github.com/users/alextarrago","html_url":"https://github.com/alextarrago","followers_url":"https://api.github.com/users/alextarrago/followers","following_url":"https://api.github.com/users/alextarrago/following{/other_user}","gists_url":"https://api.github.com/users/alextarrago/gists{/gist_id}","starred_url":"https://api.github.com/users/alextarrago/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alextarrago/subscriptions","organizations_url":"https://api.github.com/users/alextarrago/orgs","repos_url":"https://api.github.com/users/alextarrago/repos","events_url":"https://api.github.com/users/alextarrago/events{/privacy}","received_events_url":"https://api.github.com/users/alextarrago/received_events","type":"User","site_admin":false},"created_at":"2017-08-10T09:07:58Z","updated_at":"2017-08-10T09:07:58Z","body":"Thanks for the fast reply @pixelspark. I got it working later yesterday.\r\n\r\n```\r\nR.connect(URL(string: \"rethinkdb://\\(server):\\(port)\")!, user: user, password: password) { (err, connection) in\r\n    R.db(db).table(table).indexWait().run(connection) { (response) in\r\n        R.db(db).table(table).changes().run(connection) { response in\r\n            var consumeChanges: ((_ response: ReResponse) -> ())? = nil\r\n            consumeChanges = { (response: ReResponse) -> () in\r\n                if case ReResponse.rows(let docs, let cb) = response {\r\n                    self.updateDocuments(response: response)\r\n                    cb!(consumeChanges!)\r\n                }\r\n                else {\r\n                    print(\"Received unexpected response for .changes request: \\(response)\")\r\n                }\r\n            }\r\n            consumeChanges!(response)\r\n        }\r\n    }\r\n}\r\n```"}}
{"actor":{"display_login":"alextarrago"}}