Merge pull request #1309 from realm/fix-1306

Fix typescript definitions
This commit is contained in:
blagoev 2017-09-13 12:54:13 +03:00 committed by GitHub
commit 591c32f984
4 changed files with 9 additions and 14 deletions

View File

@ -95,7 +95,7 @@ class Realm {
* Open a realm asynchronously with a promise. If the realm is synced, it will be fully
* synchronized before it is available.
* @param {Realm~Configuration} config
* @returns {Promise} - a promise that will be resolved with the realm instance when it's available.
* @returns {ProgressPromise} - a promise that will be resolved with the realm instance when it's available.
*/
static open(config) {}
@ -104,9 +104,10 @@ class Realm {
* synchronized before it is available.
* @param {Realm~Configuration} config
* @param {callback(error, realm)} - will be called when the realm is ready.
* @param {callback(transferred, transferable)} [progressCallback] - an optional callback for download progress notifications
* @throws {Error} If anything in the provided `config` is invalid.
*/
static openAsync(config, callback) {}
static openAsync(config, callback, progressCallback) {}
/**
* Closes this Realm so it may be re-opened with a newer schema version.

View File

@ -76,13 +76,7 @@ module.exports = function(realmConstructor) {
return promise;
},
openAsync(config, progressCallback, callback) {
if (!callback) {
callback = progressCallback;
progressCallback = null;
}
openAsync(config, callback, progressCallback) {
realmConstructor._waitForDownload(config,
(syncSession) => {
if (progressCallback) {

4
lib/index.d.ts vendored
View File

@ -448,10 +448,10 @@ declare class Realm {
/**
* Open a realm asynchronously with a callback. If the realm is synced, it will be fully synchronized before it is available.
* @param {Configuration} config
* @param {ProgressNotificationCallback} progressCallback? a progress notification callback for 'download' direction and 'forCurrentlyOutstandingWork' mode
* @param {Function} callback will be called when the realm is ready.
* @param {ProgressNotificationCallback} progressCallback? a progress notification callback for 'download' direction and 'forCurrentlyOutstandingWork' mode
*/
static openAsync(config: Realm.Configuration, progressCallback?: Realm.Sync.ProgressNotificationCallback, callback: (error: any, realm: Realm) => void): void
static openAsync(config: Realm.Configuration, callback: (error: any, realm: Realm) => void, progressCallback?: Realm.Sync.ProgressNotificationCallback): void
/**
* Delete the Realm file for the given configuration.

View File

@ -626,9 +626,6 @@ module.exports = {
let progressCalled = false;
Realm.openAsync(config,
(transferred, total) => {
progressCalled = true;
},
(error, realm) => {
if (error) {
reject(error);
@ -637,6 +634,9 @@ module.exports = {
TestCase.assertTrue(progressCalled);
resolve();
},
(transferred, total) => {
progressCalled = true;
});
setTimeout(function() {