mirror of
https://github.com/status-im/realm-js.git
synced 2025-01-11 06:46:03 +00:00
add typescript definitions
This commit is contained in:
parent
3a8f56cdc0
commit
e5ebb75d22
18
lib/index.d.ts
vendored
18
lib/index.d.ts
vendored
@ -332,6 +332,9 @@ declare namespace Realm.Sync {
|
||||
ssl_trust_certificate_path?: string;
|
||||
}
|
||||
|
||||
type ProgressNotificationCallback = (transferred: number, total: number) => void;
|
||||
type ProgressDirection = 'download' | 'upload';
|
||||
type ProgressMode = 'reportIndefinitely' | 'forCurrentlyOutstandingWork';
|
||||
/**
|
||||
* Session
|
||||
* @see { @link https://realm.io/docs/javascript/latest/api/Realm.Sync.Session.html }
|
||||
@ -341,6 +344,9 @@ declare namespace Realm.Sync {
|
||||
readonly state: 'invalid' | 'active' | 'inactive';
|
||||
readonly url: string;
|
||||
readonly user: User;
|
||||
|
||||
addProgressNotification(direction: ProgressDirection, mode: ProgressMode, progressCallback: ProgressNotificationCallback): void;
|
||||
removeProgressNotification(progressCallback: ProgressNotificationCallback): void;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -402,6 +408,11 @@ declare namespace Realm.Sync {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
interface ProgressPromise extends Promise<Realm> {
|
||||
progress(callback: Realm.Sync.ProgressNotificationCallback) : Promise<Realm>
|
||||
}
|
||||
|
||||
declare class Realm {
|
||||
static defaultPath: string;
|
||||
|
||||
@ -422,17 +433,20 @@ declare class Realm {
|
||||
*/
|
||||
static schemaVersion(path: string, encryptionKey?: ArrayBuffer | ArrayBufferView): number;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Open a realm asynchronously with a promise. If the realm is synced, it will be fully synchronized before it is available.
|
||||
* @param {Configuration} config
|
||||
*/
|
||||
static open(config: Realm.Configuration): Promise<Realm>
|
||||
static open(config: Realm.Configuration): ProgressPromise;
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
static openAsync(config: Realm.Configuration, callback: (error: any, realm: Realm) => void): void
|
||||
static openAsync(config: Realm.Configuration, progressCallback?: Realm.Sync.ProgressNotificationCallback, callback: (error: any, realm: Realm) => void): void
|
||||
|
||||
/**
|
||||
* Delete the Realm file for the given configuration.
|
||||
|
Loading…
x
Reference in New Issue
Block a user