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)
|
||||
=============================================================
|
||||
### Breaking changes
|
||||
|
|
|
@ -72,6 +72,14 @@ class Realm {
|
|||
*/
|
||||
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
|
||||
* @type {Session}
|
||||
|
|
|
@ -60,6 +60,7 @@ function setupRealm(realm, realmId) {
|
|||
'schemaVersion',
|
||||
'syncSession',
|
||||
'isInTransaction',
|
||||
'isClosed',
|
||||
'subscribeToObjects',
|
||||
].forEach((name) => {
|
||||
Object.defineProperty(realm, name, {get: util.getterForProperty(name)});
|
||||
|
|
|
@ -458,6 +458,7 @@ declare class Realm {
|
|||
readonly schema: Realm.ObjectSchema[];
|
||||
readonly schemaVersion: number;
|
||||
readonly isInTransaction: boolean;
|
||||
readonly isClosed: boolean;
|
||||
|
||||
readonly syncSession: Realm.Sync.Session | null;
|
||||
|
||||
|
|
|
@ -198,6 +198,7 @@ public:
|
|||
static void get_in_memory(ContextType, ObjectType, ReturnValue &);
|
||||
static void get_read_only(ContextType, ObjectType, ReturnValue &);
|
||||
static void get_is_in_transaction(ContextType, ObjectType, ReturnValue &);
|
||||
static void get_is_closed(ContextType, ObjectType, ReturnValue &);
|
||||
#if REALM_ENABLE_SYNC
|
||||
static void get_sync_session(ContextType, ObjectType, ReturnValue &);
|
||||
#endif
|
||||
|
@ -259,6 +260,7 @@ public:
|
|||
{"inMemory", {wrap<get_in_memory>, nullptr}},
|
||||
{"readOnly", {wrap<get_read_only>, nullptr}},
|
||||
{"isInTransaction", {wrap<get_is_in_transaction>, nullptr}},
|
||||
{"isClosed", {wrap<get_is_closed>, nullptr}},
|
||||
#if REALM_ENABLE_SYNC
|
||||
{"syncSession", {wrap<get_sync_session>, nullptr}},
|
||||
#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());
|
||||
}
|
||||
|
||||
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
|
||||
template<typename T>
|
||||
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];
|
||||
callback_arguments[0] = object;
|
||||
|
||||
|
||||
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);
|
||||
},
|
||||
|
||||
testRealmIsClosed: function() {
|
||||
const realm = new Realm({schema: []});
|
||||
TestCase.assertFalse(realm.isClosed);
|
||||
realm.close();
|
||||
TestCase.assertTrue(realm.isClosed);
|
||||
},
|
||||
|
||||
testRealmConstructorSchemaVersion: function() {
|
||||
const defaultRealm = new Realm({schema: []});
|
||||
TestCase.assertEqual(defaultRealm.schemaVersion, 0);
|
||||
|
|
Loading…
Reference in New Issue