Adding property Realm.isClosed. (#1560)
* Adding property Realm.isClosed.
This commit is contained in:
parent
517c165c12
commit
aed1ea104b
15
CHANGELOG.md
15
CHANGELOG.md
|
@ -1,3 +1,18 @@
|
||||||
|
|
||||||
|
X.Y.Z Release notes
|
||||||
|
=============================================================
|
||||||
|
### Breaking changes
|
||||||
|
* None.
|
||||||
|
|
||||||
|
### Enhancements
|
||||||
|
* Added property `Realm.isClosed` which indicates if a Realm instance is closed or not.
|
||||||
|
|
||||||
|
### Bug fixes
|
||||||
|
* None.
|
||||||
|
|
||||||
|
### Internal
|
||||||
|
* None.
|
||||||
|
|
||||||
2.0.13 Release notes (2017-12-8)
|
2.0.13 Release notes (2017-12-8)
|
||||||
=============================================================
|
=============================================================
|
||||||
### Breaking changes
|
### Breaking changes
|
||||||
|
|
|
@ -72,6 +72,14 @@ class Realm {
|
||||||
*/
|
*/
|
||||||
get isInTransaction() {}
|
get isInTransaction() {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Indicates if this Realm has been closed.
|
||||||
|
* @type {boolean}
|
||||||
|
* @readonly
|
||||||
|
* @since 2.1.0
|
||||||
|
*/
|
||||||
|
get isClosed() {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the sync session if this is a synced Realm
|
* Gets the sync session if this is a synced Realm
|
||||||
* @type {Session}
|
* @type {Session}
|
||||||
|
|
|
@ -60,6 +60,7 @@ function setupRealm(realm, realmId) {
|
||||||
'schemaVersion',
|
'schemaVersion',
|
||||||
'syncSession',
|
'syncSession',
|
||||||
'isInTransaction',
|
'isInTransaction',
|
||||||
|
'isClosed',
|
||||||
'subscribeToObjects',
|
'subscribeToObjects',
|
||||||
].forEach((name) => {
|
].forEach((name) => {
|
||||||
Object.defineProperty(realm, name, {get: util.getterForProperty(name)});
|
Object.defineProperty(realm, name, {get: util.getterForProperty(name)});
|
||||||
|
|
|
@ -458,6 +458,7 @@ declare class Realm {
|
||||||
readonly schema: Realm.ObjectSchema[];
|
readonly schema: Realm.ObjectSchema[];
|
||||||
readonly schemaVersion: number;
|
readonly schemaVersion: number;
|
||||||
readonly isInTransaction: boolean;
|
readonly isInTransaction: boolean;
|
||||||
|
readonly isClosed: boolean;
|
||||||
|
|
||||||
readonly syncSession: Realm.Sync.Session | null;
|
readonly syncSession: Realm.Sync.Session | null;
|
||||||
|
|
||||||
|
|
|
@ -198,6 +198,7 @@ public:
|
||||||
static void get_in_memory(ContextType, ObjectType, ReturnValue &);
|
static void get_in_memory(ContextType, ObjectType, ReturnValue &);
|
||||||
static void get_read_only(ContextType, ObjectType, ReturnValue &);
|
static void get_read_only(ContextType, ObjectType, ReturnValue &);
|
||||||
static void get_is_in_transaction(ContextType, ObjectType, ReturnValue &);
|
static void get_is_in_transaction(ContextType, ObjectType, ReturnValue &);
|
||||||
|
static void get_is_closed(ContextType, ObjectType, ReturnValue &);
|
||||||
#if REALM_ENABLE_SYNC
|
#if REALM_ENABLE_SYNC
|
||||||
static void get_sync_session(ContextType, ObjectType, ReturnValue &);
|
static void get_sync_session(ContextType, ObjectType, ReturnValue &);
|
||||||
#endif
|
#endif
|
||||||
|
@ -259,6 +260,7 @@ public:
|
||||||
{"inMemory", {wrap<get_in_memory>, nullptr}},
|
{"inMemory", {wrap<get_in_memory>, nullptr}},
|
||||||
{"readOnly", {wrap<get_read_only>, nullptr}},
|
{"readOnly", {wrap<get_read_only>, nullptr}},
|
||||||
{"isInTransaction", {wrap<get_is_in_transaction>, nullptr}},
|
{"isInTransaction", {wrap<get_is_in_transaction>, nullptr}},
|
||||||
|
{"isClosed", {wrap<get_is_closed>, nullptr}},
|
||||||
#if REALM_ENABLE_SYNC
|
#if REALM_ENABLE_SYNC
|
||||||
{"syncSession", {wrap<get_sync_session>, nullptr}},
|
{"syncSession", {wrap<get_sync_session>, nullptr}},
|
||||||
#endif
|
#endif
|
||||||
|
@ -694,6 +696,11 @@ void RealmClass<T>::get_is_in_transaction(ContextType ctx, ObjectType object, Re
|
||||||
return_value.set(get_internal<T, RealmClass<T>>(object)->get()->is_in_transaction());
|
return_value.set(get_internal<T, RealmClass<T>>(object)->get()->is_in_transaction());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
void RealmClass<T>::get_is_closed(ContextType ctx, ObjectType object, ReturnValue &return_value) {
|
||||||
|
return_value.set(get_internal<T, RealmClass<T>>(object)->get()->is_closed());
|
||||||
|
}
|
||||||
|
|
||||||
#if REALM_ENABLE_SYNC
|
#if REALM_ENABLE_SYNC
|
||||||
template<typename T>
|
template<typename T>
|
||||||
void RealmClass<T>::get_sync_session(ContextType ctx, ObjectType object, ReturnValue &return_value) {
|
void RealmClass<T>::get_sync_session(ContextType ctx, ObjectType object, ReturnValue &return_value) {
|
||||||
|
@ -738,7 +745,7 @@ void RealmClass<T>::wait_for_download_completion(ContextType ctx, ObjectType thi
|
||||||
|
|
||||||
ValueType callback_arguments[1];
|
ValueType callback_arguments[1];
|
||||||
callback_arguments[0] = object;
|
callback_arguments[0] = object;
|
||||||
|
|
||||||
Function<T>::callback(protected_ctx, protected_callback, typename T::Object(), 1, callback_arguments);
|
Function<T>::callback(protected_ctx, protected_callback, typename T::Object(), 1, callback_arguments);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -57,6 +57,13 @@ module.exports = {
|
||||||
TestCase.assertEqual(realm2.path, defaultDir + testPath2);
|
TestCase.assertEqual(realm2.path, defaultDir + testPath2);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
testRealmIsClosed: function() {
|
||||||
|
const realm = new Realm({schema: []});
|
||||||
|
TestCase.assertFalse(realm.isClosed);
|
||||||
|
realm.close();
|
||||||
|
TestCase.assertTrue(realm.isClosed);
|
||||||
|
},
|
||||||
|
|
||||||
testRealmConstructorSchemaVersion: function() {
|
testRealmConstructorSchemaVersion: function() {
|
||||||
const defaultRealm = new Realm({schema: []});
|
const defaultRealm = new Realm({schema: []});
|
||||||
TestCase.assertEqual(defaultRealm.schemaVersion, 0);
|
TestCase.assertEqual(defaultRealm.schemaVersion, 0);
|
||||||
|
|
Loading…
Reference in New Issue