Merge pull request #1146 from realm/ni/open-async

Don’t invoke openAsync callback twice
This commit is contained in:
blagoev 2017-07-27 13:26:57 +03:00 committed by GitHub
commit c090cd9700
2 changed files with 25 additions and 14 deletions

View File

@ -1,3 +1,12 @@
vNext (TBD)
=============================================================
### Breaking changes
* `Realm.openAsync` will no longer open the realm if an error has occured. Previously this resulted in the callback being invoked twice - once with an error and a second time - with the synchronously opened Realm.
### Enhancements
### Bug fixes
1.10.0 Release notes (2017-7-12)
=============================================================
### Breaking changes

View File

@ -48,13 +48,14 @@ module.exports = function(realmConstructor) {
if (error) {
reject(error);
}
try {
let syncedRealm = new this(config);
//FIXME: RN hangs here. Remove when node's makeCallback alternative is implemented
setTimeout(() => { resolve(syncedRealm); }, 1);
} catch (e) {
reject(e);
else {
try {
let syncedRealm = new this(config);
//FIXME: RN hangs here. Remove when node's makeCallback alternative is implemented
setTimeout(() => { resolve(syncedRealm); }, 1);
} catch (e) {
reject(e);
}
}
});
});
@ -65,13 +66,14 @@ module.exports = function(realmConstructor) {
if (error) {
callback(error);
}
try {
let syncedRealm = new this(config);
//FIXME: RN hangs here. Remove when node's makeCallback alternative is implemented
setTimeout(() => { callback(null, syncedRealm); }, 1);
} catch (e) {
callback(e);
else {
try {
let syncedRealm = new this(config);
//FIXME: RN hangs here. Remove when node's makeCallback alternative is implemented
setTimeout(() => { callback(null, syncedRealm); }, 1);
} catch (e) {
callback(e);
}
}
});
},