{"action":"created","comment":{"url":"https://api.github.com/repos/Nozbe/WatermelonDB/pulls/comments/223978373","pull_request_review_id":163234237,"id":223978373,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIyMzk3ODM3Mw==","diff_hunk":"@@ -6,93 +6,181 @@ import com.facebook.react.bridge.ReactContextBaseJavaModule\n import com.facebook.react.bridge.ReactMethod\n import com.facebook.react.bridge.Promise\n import com.facebook.react.bridge.ReadableArray\n+import com.facebook.react.bridge.Arguments\n import com.nozbe.watermelondb.DatabaseDriver.Operation\n \n class DatabaseBridge(private val reactContext: ReactApplicationContext) :\n         ReactContextBaseJavaModule(reactContext) {\n \n-    private val connections: MutableMap<ConnectionTag, DatabaseDriver> = mutableMapOf()\n+    private val connections: MutableMap<ConnectionTag, Connection> = mutableMapOf()\n \n     override fun getName(): String = \"DatabaseBridge\"\n \n+    sealed class Connection {\n+        class Connected(val driver: DatabaseDriver) : Connection()\n+        class Waiting(var queueW: ArrayList<(() -> Unit)>) : Connection()\n+\n+        var queue: ArrayList<(() -> Unit)> = arrayListOf()\n+            get() = when (this) {\n+                is Connection.Connected -> arrayListOf()\n+                is Connection.Waiting -> this.queueW\n+            }\n+    }\n+\n     @ReactMethod\n-    fun setUp(\n+    fun initialize(\n         tag: ConnectionTag,\n         databaseName: String,\n-        schema: SQL,\n         schemaVersion: Int,\n         promise: Promise\n     ) {\n-        val driver = DatabaseDriver(\n-                reactContext,\n-                DatabaseDriver.Configuration(\n-                        databaseName,\n-                        schema,\n-                        schemaVersion\n-                )\n-        )\n-        connections[tag] = driver\n-        promise.resolve(true)\n+        assert(connections[tag] == null) { \"A driver with tag $tag already set up\" }\n+        val promiseMap = Arguments.createMap()\n+\n+        try {\n+            connections[tag] = Connection.Connected(\n+                    driver = DatabaseDriver(","path":"native/android/src/main/java/com/nozbe/watermelondb/DatabaseBridge.kt","position":50,"original_position":50,"commit_id":"a609b333582ab7efc77ff0540c7a805176b2b081","original_commit_id":"cb04f318f9ad3863984a05ba09894be8b6fb3c4e","user":{"login":"kokusGr","id":28709559,"node_id":"MDQ6VXNlcjI4NzA5NTU5","avatar_url":"https://avatars1.githubusercontent.com/u/28709559?v=4","gravatar_id":"","url":"https://api.github.com/users/kokusGr","html_url":"https://github.com/kokusGr","followers_url":"https://api.github.com/users/kokusGr/followers","following_url":"https://api.github.com/users/kokusGr/following{/other_user}","gists_url":"https://api.github.com/users/kokusGr/gists{/gist_id}","starred_url":"https://api.github.com/users/kokusGr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kokusGr/subscriptions","organizations_url":"https://api.github.com/users/kokusGr/orgs","repos_url":"https://api.github.com/users/kokusGr/repos","events_url":"https://api.github.com/users/kokusGr/events{/privacy}","received_events_url":"https://api.github.com/users/kokusGr/received_events","type":"User","site_admin":false},"body":"👌 ","created_at":"2018-10-10T08:20:51Z","updated_at":"2018-10-10T08:20:51Z","html_url":"https://github.com/Nozbe/WatermelonDB/pull/78#discussion_r223978373","pull_request_url":"https://api.github.com/repos/Nozbe/WatermelonDB/pulls/78","author_association":"COLLABORATOR","_links":{"self":{"href":"https://api.github.com/repos/Nozbe/WatermelonDB/pulls/comments/223978373"},"html":{"href":"https://github.com/Nozbe/WatermelonDB/pull/78#discussion_r223978373"},"pull_request":{"href":"https://api.github.com/repos/Nozbe/WatermelonDB/pulls/78"}},"in_reply_to_id":223653804},"pull_request":{"url":"https://api.github.com/repos/Nozbe/WatermelonDB/pulls/78","id":221329059,"node_id":"MDExOlB1bGxSZXF1ZXN0MjIxMzI5MDU5","html_url":"https://github.com/Nozbe/WatermelonDB/pull/78","diff_url":"https://github.com/Nozbe/WatermelonDB/pull/78.diff","patch_url":"https://github.com/Nozbe/WatermelonDB/pull/78.patch","issue_url":"https://api.github.com/repos/Nozbe/WatermelonDB/issues/78","number":78,"state":"open","locked":false,"title":"Android lazy schema loading","user":{"login":"rozPierog","id":23499434,"node_id":"MDQ6VXNlcjIzNDk5NDM0","avatar_url":"https://avatars1.githubusercontent.com/u/23499434?v=4","gravatar_id":"","url":"https://api.github.com/users/rozPierog","html_url":"https://github.com/rozPierog","followers_url":"https://api.github.com/users/rozPierog/followers","following_url":"https://api.github.com/users/rozPierog/following{/other_user}","gists_url":"https://api.github.com/users/rozPierog/gists{/gist_id}","starred_url":"https://api.github.com/users/rozPierog/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rozPierog/subscriptions","organizations_url":"https://api.github.com/users/rozPierog/orgs","repos_url":"https://api.github.com/users/rozPierog/repos","events_url":"https://api.github.com/users/rozPierog/events{/privacy}","received_events_url":"https://api.github.com/users/rozPierog/received_events","type":"User","site_admin":false},"body":"Same thing as https://github.com/Nozbe/WatermelonDB/pull/67 but for Android ","created_at":"2018-10-09T07:07:15Z","updated_at":"2018-10-10T08:20:51Z","closed_at":null,"merged_at":null,"merge_commit_sha":"e5a99fa9ce6646453807638b2323c23e671302a7","assignee":{"login":"kokusGr","id":28709559,"node_id":"MDQ6VXNlcjI4NzA5NTU5","avatar_url":"https://avatars1.githubusercontent.com/u/28709559?v=4","gravatar_id":"","url":"https://api.github.com/users/kokusGr","html_url":"https://github.com/kokusGr","followers_url":"https://api.github.com/users/kokusGr/followers","following_url":"https://api.github.com/users/kokusGr/following{/other_user}","gists_url":"https://api.github.com/users/kokusGr/gists{/gist_id}","starred_url":"https://api.github.com/users/kokusGr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kokusGr/subscriptions","organizations_url":"https://api.github.com/users/kokusGr/orgs","repos_url":"https://api.github.com/users/kokusGr/repos","events_url":"https://api.github.com/users/kokusGr/events{/privacy}","received_events_url":"https://api.github.com/users/kokusGr/received_events","type":"User","site_admin":false},"assignees":[{"login":"kokusGr","id":28709559,"node_id":"MDQ6VXNlcjI4NzA5NTU5","avatar_url":"https://avatars1.githubusercontent.com/u/28709559?v=4","gravatar_id":"","url":"https://api.github.com/users/kokusGr","html_url":"https://github.com/kokusGr","followers_url":"https://api.github.com/users/kokusGr/followers","following_url":"https://api.github.com/users/kokusGr/following{/other_user}","gists_url":"https://api.github.com/users/kokusGr/gists{/gist_id}","starred_url":"https://api.github.com/users/kokusGr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kokusGr/subscriptions","organizations_url":"https://api.github.com/users/kokusGr/orgs","repos_url":"https://api.github.com/users/kokusGr/repos","events_url":"https://api.github.com/users/kokusGr/events{/privacy}","received_events_url":"https://api.github.com/users/kokusGr/received_events","type":"User","site_admin":false}],"requested_reviewers":[{"login":"radex","id":183747,"node_id":"MDQ6VXNlcjE4Mzc0Nw==","avatar_url":"https://avatars2.githubusercontent.com/u/183747?v=4","gravatar_id":"","url":"https://api.github.com/users/radex","html_url":"https://github.com/radex","followers_url":"https://api.github.com/users/radex/followers","following_url":"https://api.github.com/users/radex/following{/other_user}","gists_url":"https://api.github.com/users/radex/gists{/gist_id}","starred_url":"https://api.github.com/users/radex/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/radex/subscriptions","organizations_url":"https://api.github.com/users/radex/orgs","repos_url":"https://api.github.com/users/radex/repos","events_url":"https://api.github.com/users/radex/events{/privacy}","received_events_url":"https://api.github.com/users/radex/received_events","type":"User","site_admin":false}],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/Nozbe/WatermelonDB/pulls/78/commits","review_comments_url":"https://api.github.com/repos/Nozbe/WatermelonDB/pulls/78/comments","review_comment_url":"https://api.github.com/repos/Nozbe/WatermelonDB/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Nozbe/WatermelonDB/issues/78/comments","statuses_url":"https://api.github.com/repos/Nozbe/WatermelonDB/statuses/a609b333582ab7efc77ff0540c7a805176b2b081","head":{"label":"Nozbe:android-schema-on-demand","ref":"android-schema-on-demand","sha":"a609b333582ab7efc77ff0540c7a805176b2b081","user":{"login":"Nozbe","id":1301067,"node_id":"MDEyOk9yZ2FuaXphdGlvbjEzMDEwNjc=","avatar_url":"https://avatars3.githubusercontent.com/u/1301067?v=4","gravatar_id":"","url":"https://api.github.com/users/Nozbe","html_url":"https://github.com/Nozbe","followers_url":"https://api.github.com/users/Nozbe/followers","following_url":"https://api.github.com/users/Nozbe/following{/other_user}","gists_url":"https://api.github.com/users/Nozbe/gists{/gist_id}","starred_url":"https://api.github.com/users/Nozbe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Nozbe/subscriptions","organizations_url":"https://api.github.com/users/Nozbe/orgs","repos_url":"https://api.github.com/users/Nozbe/repos","events_url":"https://api.github.com/users/Nozbe/events{/privacy}","received_events_url":"https://api.github.com/users/Nozbe/received_events","type":"Organization","site_admin":false},"repo":{"id":146468829,"node_id":"MDEwOlJlcG9zaXRvcnkxNDY0Njg4Mjk=","name":"WatermelonDB","full_name":"Nozbe/WatermelonDB","private":false,"owner":{"login":"Nozbe","id":1301067,"node_id":"MDEyOk9yZ2FuaXphdGlvbjEzMDEwNjc=","avatar_url":"https://avatars3.githubusercontent.com/u/1301067?v=4","gravatar_id":"","url":"https://api.github.com/users/Nozbe","html_url":"https://github.com/Nozbe","followers_url":"https://api.github.com/users/Nozbe/followers","following_url":"https://api.github.com/users/Nozbe/following{/other_user}","gists_url":"https://api.github.com/users/Nozbe/gists{/gist_id}","starred_url":"https://api.github.com/users/Nozbe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Nozbe/subscriptions","organizations_url":"https://api.github.com/users/Nozbe/orgs","repos_url":"https://api.github.com/users/Nozbe/repos","events_url":"https://api.github.com/users/Nozbe/events{/privacy}","received_events_url":"https://api.github.com/users/Nozbe/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/Nozbe/WatermelonDB","description":"🍉 Next-gen database for powerful React and React Native apps that scales to 10,000s of records and remains fast ⚡️","fork":false,"url":"https://api.github.com/repos/Nozbe/WatermelonDB","forks_url":"https://api.github.com/repos/Nozbe/WatermelonDB/forks","keys_url":"https://api.github.com/repos/Nozbe/WatermelonDB/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Nozbe/WatermelonDB/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Nozbe/WatermelonDB/teams","hooks_url":"https://api.github.com/repos/Nozbe/WatermelonDB/hooks","issue_events_url":"https://api.github.com/repos/Nozbe/WatermelonDB/issues/events{/number}","events_url":"https://api.github.com/repos/Nozbe/WatermelonDB/events","assignees_url":"https://api.github.com/repos/Nozbe/WatermelonDB/assignees{/user}","branches_url":"https://api.github.com/repos/Nozbe/WatermelonDB/branches{/branch}","tags_url":"https://api.github.com/repos/Nozbe/WatermelonDB/tags","blobs_url":"https://api.github.com/repos/Nozbe/WatermelonDB/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Nozbe/WatermelonDB/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Nozbe/WatermelonDB/git/refs{/sha}","trees_url":"https://api.github.com/repos/Nozbe/WatermelonDB/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Nozbe/WatermelonDB/statuses/{sha}","languages_url":"https://api.github.com/repos/Nozbe/WatermelonDB/languages","stargazers_url":"https://api.github.com/repos/Nozbe/WatermelonDB/stargazers","contributors_url":"https://api.github.com/repos/Nozbe/WatermelonDB/contributors","subscribers_url":"https://api.github.com/repos/Nozbe/WatermelonDB/subscribers","subscription_url":"https://api.github.com/repos/Nozbe/WatermelonDB/subscription","commits_url":"https://api.github.com/repos/Nozbe/WatermelonDB/commits{/sha}","git_commits_url":"https://api.github.com/repos/Nozbe/WatermelonDB/git/commits{/sha}","comments_url":"https://api.github.com/repos/Nozbe/WatermelonDB/comments{/number}","issue_comment_url":"https://api.github.com/repos/Nozbe/WatermelonDB/issues/comments{/number}","contents_url":"https://api.github.com/repos/Nozbe/WatermelonDB/contents/{+path}","compare_url":"https://api.github.com/repos/Nozbe/WatermelonDB/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Nozbe/WatermelonDB/merges","archive_url":"https://api.github.com/repos/Nozbe/WatermelonDB/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Nozbe/WatermelonDB/downloads","issues_url":"https://api.github.com/repos/Nozbe/WatermelonDB/issues{/number}","pulls_url":"https://api.github.com/repos/Nozbe/WatermelonDB/pulls{/number}","milestones_url":"https://api.github.com/repos/Nozbe/WatermelonDB/milestones{/number}","notifications_url":"https://api.github.com/repos/Nozbe/WatermelonDB/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Nozbe/WatermelonDB/labels{/name}","releases_url":"https://api.github.com/repos/Nozbe/WatermelonDB/releases{/id}","deployments_url":"https://api.github.com/repos/Nozbe/WatermelonDB/deployments","created_at":"2018-08-28T15:32:05Z","updated_at":"2018-10-10T08:13:46Z","pushed_at":"2018-10-10T07:27:48Z","git_url":"git://github.com/Nozbe/WatermelonDB.git","ssh_url":"git@github.com:Nozbe/WatermelonDB.git","clone_url":"https://github.com/Nozbe/WatermelonDB.git","svn_url":"https://github.com/Nozbe/WatermelonDB","homepage":"https://watermelondb.now.sh","size":3863,"stargazers_count":4221,"watchers_count":4221,"language":"JavaScript","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":109,"mirror_url":null,"archived":false,"open_issues_count":28,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":109,"open_issues":28,"watchers":4221,"default_branch":"master"}},"base":{"label":"Nozbe:adapter-testing","ref":"adapter-testing","sha":"83affc7cfd978ced24b934ac5062c70a52aed68a","user":{"login":"Nozbe","id":1301067,"node_id":"MDEyOk9yZ2FuaXphdGlvbjEzMDEwNjc=","avatar_url":"https://avatars3.githubusercontent.com/u/1301067?v=4","gravatar_id":"","url":"https://api.github.com/users/Nozbe","html_url":"https://github.com/Nozbe","followers_url":"https://api.github.com/users/Nozbe/followers","following_url":"https://api.github.com/users/Nozbe/following{/other_user}","gists_url":"https://api.github.com/users/Nozbe/gists{/gist_id}","starred_url":"https://api.github.com/users/Nozbe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Nozbe/subscriptions","organizations_url":"https://api.github.com/users/Nozbe/orgs","repos_url":"https://api.github.com/users/Nozbe/repos","events_url":"https://api.github.com/users/Nozbe/events{/privacy}","received_events_url":"https://api.github.com/users/Nozbe/received_events","type":"Organization","site_admin":false},"repo":{"id":146468829,"node_id":"MDEwOlJlcG9zaXRvcnkxNDY0Njg4Mjk=","name":"WatermelonDB","full_name":"Nozbe/WatermelonDB","private":false,"owner":{"login":"Nozbe","id":1301067,"node_id":"MDEyOk9yZ2FuaXphdGlvbjEzMDEwNjc=","avatar_url":"https://avatars3.githubusercontent.com/u/1301067?v=4","gravatar_id":"","url":"https://api.github.com/users/Nozbe","html_url":"https://github.com/Nozbe","followers_url":"https://api.github.com/users/Nozbe/followers","following_url":"https://api.github.com/users/Nozbe/following{/other_user}","gists_url":"https://api.github.com/users/Nozbe/gists{/gist_id}","starred_url":"https://api.github.com/users/Nozbe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Nozbe/subscriptions","organizations_url":"https://api.github.com/users/Nozbe/orgs","repos_url":"https://api.github.com/users/Nozbe/repos","events_url":"https://api.github.com/users/Nozbe/events{/privacy}","received_events_url":"https://api.github.com/users/Nozbe/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/Nozbe/WatermelonDB","description":"🍉 Next-gen database for powerful React and React Native apps that scales to 10,000s of records and remains fast ⚡️","fork":false,"url":"https://api.github.com/repos/Nozbe/WatermelonDB","forks_url":"https://api.github.com/repos/Nozbe/WatermelonDB/forks","keys_url":"https://api.github.com/repos/Nozbe/WatermelonDB/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Nozbe/WatermelonDB/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Nozbe/WatermelonDB/teams","hooks_url":"https://api.github.com/repos/Nozbe/WatermelonDB/hooks","issue_events_url":"https://api.github.com/repos/Nozbe/WatermelonDB/issues/events{/number}","events_url":"https://api.github.com/repos/Nozbe/WatermelonDB/events","assignees_url":"https://api.github.com/repos/Nozbe/WatermelonDB/assignees{/user}","branches_url":"https://api.github.com/repos/Nozbe/WatermelonDB/branches{/branch}","tags_url":"https://api.github.com/repos/Nozbe/WatermelonDB/tags","blobs_url":"https://api.github.com/repos/Nozbe/WatermelonDB/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Nozbe/WatermelonDB/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Nozbe/WatermelonDB/git/refs{/sha}","trees_url":"https://api.github.com/repos/Nozbe/WatermelonDB/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Nozbe/WatermelonDB/statuses/{sha}","languages_url":"https://api.github.com/repos/Nozbe/WatermelonDB/languages","stargazers_url":"https://api.github.com/repos/Nozbe/WatermelonDB/stargazers","contributors_url":"https://api.github.com/repos/Nozbe/WatermelonDB/contributors","subscribers_url":"https://api.github.com/repos/Nozbe/WatermelonDB/subscribers","subscription_url":"https://api.github.com/repos/Nozbe/WatermelonDB/subscription","commits_url":"https://api.github.com/repos/Nozbe/WatermelonDB/commits{/sha}","git_commits_url":"https://api.github.com/repos/Nozbe/WatermelonDB/git/commits{/sha}","comments_url":"https://api.github.com/repos/Nozbe/WatermelonDB/comments{/number}","issue_comment_url":"https://api.github.com/repos/Nozbe/WatermelonDB/issues/comments{/number}","contents_url":"https://api.github.com/repos/Nozbe/WatermelonDB/contents/{+path}","compare_url":"https://api.github.com/repos/Nozbe/WatermelonDB/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Nozbe/WatermelonDB/merges","archive_url":"https://api.github.com/repos/Nozbe/WatermelonDB/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Nozbe/WatermelonDB/downloads","issues_url":"https://api.github.com/repos/Nozbe/WatermelonDB/issues{/number}","pulls_url":"https://api.github.com/repos/Nozbe/WatermelonDB/pulls{/number}","milestones_url":"https://api.github.com/repos/Nozbe/WatermelonDB/milestones{/number}","notifications_url":"https://api.github.com/repos/Nozbe/WatermelonDB/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Nozbe/WatermelonDB/labels{/name}","releases_url":"https://api.github.com/repos/Nozbe/WatermelonDB/releases{/id}","deployments_url":"https://api.github.com/repos/Nozbe/WatermelonDB/deployments","created_at":"2018-08-28T15:32:05Z","updated_at":"2018-10-10T08:13:46Z","pushed_at":"2018-10-10T07:27:48Z","git_url":"git://github.com/Nozbe/WatermelonDB.git","ssh_url":"git@github.com:Nozbe/WatermelonDB.git","clone_url":"https://github.com/Nozbe/WatermelonDB.git","svn_url":"https://github.com/Nozbe/WatermelonDB","homepage":"https://watermelondb.now.sh","size":3863,"stargazers_count":4221,"watchers_count":4221,"language":"JavaScript","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":109,"mirror_url":null,"archived":false,"open_issues_count":28,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":109,"open_issues":28,"watchers":4221,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Nozbe/WatermelonDB/pulls/78"},"html":{"href":"https://github.com/Nozbe/WatermelonDB/pull/78"},"issue":{"href":"https://api.github.com/repos/Nozbe/WatermelonDB/issues/78"},"comments":{"href":"https://api.github.com/repos/Nozbe/WatermelonDB/issues/78/comments"},"review_comments":{"href":"https://api.github.com/repos/Nozbe/WatermelonDB/pulls/78/comments"},"review_comment":{"href":"https://api.github.com/repos/Nozbe/WatermelonDB/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Nozbe/WatermelonDB/pulls/78/commits"},"statuses":{"href":"https://api.github.com/repos/Nozbe/WatermelonDB/statuses/a609b333582ab7efc77ff0540c7a805176b2b081"}},"author_association":"COLLABORATOR"}}
{"actor":{"display_login":"kokusGr"}}