mirror of
https://github.com/status-im/realm-js.git
synced 2025-02-24 04:08:23 +00:00
Add checks for removeListener
This commit is contained in:
parent
1d4bb7c2ad
commit
43d94d1b8b
@ -652,6 +652,9 @@ void RealmClass<T>::remove_listener(ContextType ctx, ObjectType this_object, siz
|
||||
auto callback = Value::validated_to_function(ctx, arguments[1]);
|
||||
|
||||
SharedRealm realm = *get_internal<T, RealmClass<T>>(this_object);
|
||||
if (realm->is_closed()) {
|
||||
throw ClosedRealmException();
|
||||
}
|
||||
get_delegate<T>(realm.get())->remove_notification(callback);
|
||||
}
|
||||
|
||||
@ -663,6 +666,9 @@ void RealmClass<T>::remove_all_listeners(ContextType ctx, ObjectType this_object
|
||||
}
|
||||
|
||||
SharedRealm realm = *get_internal<T, RealmClass<T>>(this_object);
|
||||
if (realm->is_closed()) {
|
||||
throw ClosedRealmException();
|
||||
}
|
||||
get_delegate<T>(realm.get())->remove_all_notifications();
|
||||
}
|
||||
|
||||
|
@ -656,6 +656,8 @@ module.exports = {
|
||||
});
|
||||
|
||||
var person = realm.objects('PersonObject')[0];
|
||||
var listenerCallback = () => {};
|
||||
realm.addListener('change', listenerCallback);
|
||||
|
||||
// The tests below assert that everthing throws when
|
||||
// operating on a closed realm
|
||||
@ -689,7 +691,13 @@ module.exports = {
|
||||
realm.write(() => {});
|
||||
});
|
||||
|
||||
TestCase.assertThrows(function() {
|
||||
realm.removeListener('change', listenerCallback);
|
||||
});
|
||||
|
||||
TestCase.assertThrows(function() {
|
||||
realm.removeAllListeners();
|
||||
});
|
||||
},
|
||||
|
||||
testRealmObjectForPrimaryKey: function() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user