implement list notification removal

This commit is contained in:
Ari Lazier 2016-06-30 11:06:28 -07:00
parent 555718bf86
commit b1db10e177
2 changed files with 5 additions and 3 deletions

View File

@ -273,6 +273,7 @@ void ListClass<T>::remove_listener(ContextType ctx, ObjectType this_object, size
auto list = get_internal<T, ListClass<T>>(this_object);
auto callback = Value::validated_to_function(ctx, arguments[0]);
list->m_notification_tokens.erase(Protected<FunctionType>(ctx, callback));
}
template<typename T>
@ -280,6 +281,7 @@ void ListClass<T>::remove_all_listeners(ContextType ctx, ObjectType this_object,
validate_argument_count(argc, 0);
auto list = get_internal<T, ListClass<T>>(this_object);
list->m_notification_tokens.clear();
}
} // js

View File

@ -247,12 +247,12 @@ class Protected {
bool operator!=(const ValueType &) const;
bool operator==(const Protected<ValueType> &) const;
bool operator!=(const Protected<ValueType> &) const;
struct Comparator {
bool operator()(const Protected<ValueType>& a, const Protected<ValueType>& b) const;
};
};
template<typename T>
struct Exception : public std::runtime_error {
using ContextType = typename T::Context;
@ -292,7 +292,7 @@ struct ReturnValue {
void set_null();
void set_undefined();
};
template<typename T, typename ClassType>
REALM_JS_INLINE typename T::Object create_object(typename T::Context ctx, typename ClassType::Internal* internal = nullptr) {
return Object<T>::template create_instance<ClassType>(ctx, internal);