fix for list notifications
This commit is contained in:
parent
9fd0adf147
commit
5916936db4
|
@ -5,12 +5,14 @@
|
|||
},
|
||||
"DVTSourceControlWorkspaceBlueprintWorkingCopyStatesKey" : {
|
||||
"40F53A12E4AE40C654358321B91166ABD3E910A6" : 0,
|
||||
"F6F96CA34C5878B0A9123C7C37855491A5E599DA" : 0
|
||||
"F6F96CA34C5878B0A9123C7C37855491A5E599DA" : 0,
|
||||
"8F3C415DA79CDA7D23734F285B95F9F9A3C0CB81" : 0
|
||||
},
|
||||
"DVTSourceControlWorkspaceBlueprintIdentifierKey" : "5EE721F9-041C-4877-9E73-A925C9DB080A",
|
||||
"DVTSourceControlWorkspaceBlueprintWorkingCopyPathsKey" : {
|
||||
"40F53A12E4AE40C654358321B91166ABD3E910A6" : "realm-js\/",
|
||||
"F6F96CA34C5878B0A9123C7C37855491A5E599DA" : "realm-js\/vendor\/GCDWebServer\/"
|
||||
"F6F96CA34C5878B0A9123C7C37855491A5E599DA" : "realm-js\/vendor\/GCDWebServer\/",
|
||||
"8F3C415DA79CDA7D23734F285B95F9F9A3C0CB81" : "realm-js\/src\/object-store\/"
|
||||
},
|
||||
"DVTSourceControlWorkspaceBlueprintNameKey" : "Realm",
|
||||
"DVTSourceControlWorkspaceBlueprintVersion" : 204,
|
||||
|
@ -21,6 +23,11 @@
|
|||
"DVTSourceControlWorkspaceBlueprintRemoteRepositorySystemKey" : "com.apple.dt.Xcode.sourcecontrol.Git",
|
||||
"DVTSourceControlWorkspaceBlueprintRemoteRepositoryIdentifierKey" : "40F53A12E4AE40C654358321B91166ABD3E910A6"
|
||||
},
|
||||
{
|
||||
"DVTSourceControlWorkspaceBlueprintRemoteRepositoryURLKey" : "https:\/\/github.com\/realm\/realm-object-store.git",
|
||||
"DVTSourceControlWorkspaceBlueprintRemoteRepositorySystemKey" : "com.apple.dt.Xcode.sourcecontrol.Git",
|
||||
"DVTSourceControlWorkspaceBlueprintRemoteRepositoryIdentifierKey" : "8F3C415DA79CDA7D23734F285B95F9F9A3C0CB81"
|
||||
},
|
||||
{
|
||||
"DVTSourceControlWorkspaceBlueprintRemoteRepositoryURLKey" : "https:\/\/github.com\/swisspol\/GCDWebServer.git",
|
||||
"DVTSourceControlWorkspaceBlueprintRemoteRepositorySystemKey" : "com.apple.dt.Xcode.sourcecontrol.Git",
|
||||
|
|
|
@ -259,12 +259,13 @@ void ListClass<T>::add_listener(ContextType ctx, ObjectType this_object, size_t
|
|||
Protected<ObjectType> protected_this(ctx, this_object);
|
||||
Protected<typename T::GlobalContext> protected_ctx(Context<T>::get_global_context(ctx));
|
||||
|
||||
list->add_notification_callback([=](CollectionChangeSet change_set, std::exception_ptr exception) {
|
||||
auto token = list->add_notification_callback([=](CollectionChangeSet change_set, std::exception_ptr exception) {
|
||||
ValueType arguments[2];
|
||||
arguments[0] = static_cast<ObjectType>(protected_this);
|
||||
arguments[1] = Value::from_undefined(protected_ctx);
|
||||
arguments[1] = CollectionClass<T>::create_collection_change_set(protected_ctx, change_set);
|
||||
Function<T>::call(protected_ctx, protected_callback, protected_this, 2, arguments);
|
||||
});
|
||||
list->m_notification_tokens.emplace(protected_callback, std::move(token));
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
|
|
|
@ -163,5 +163,34 @@ module.exports = {
|
|||
[[], [], [0, 2]]
|
||||
]
|
||||
);
|
||||
}
|
||||
},
|
||||
|
||||
testListAddNotifications() {
|
||||
let ListObject = {
|
||||
name: 'ListObject',
|
||||
primaryKey: 'id',
|
||||
properties: {
|
||||
id: 'int',
|
||||
list: {type: 'list', objectType: 'TestObject'},
|
||||
}
|
||||
};
|
||||
var config = { schema: [schemas.TestObject, ListObject] };
|
||||
return createCollectionChangeTest(
|
||||
config,
|
||||
function(realm) {
|
||||
let listObject;
|
||||
realm.write(() => {
|
||||
listObject = realm.create('ListObject', {id: 0, list: []})
|
||||
});
|
||||
return listObject.list;
|
||||
},
|
||||
[
|
||||
[config, 'list_method', 'ListObject', 'list', 'push', {doubleCol: 0}, {doubleCol: 1}]
|
||||
],
|
||||
[
|
||||
[[], [], []],
|
||||
[[0, 1], [], []]
|
||||
]
|
||||
);
|
||||
},
|
||||
};
|
||||
|
|
|
@ -44,6 +44,11 @@ function handleMessage(message) {
|
|||
else if (message[1] == 'update') {
|
||||
result = message[3].map((value) => realm.create(message[2], value, true));
|
||||
}
|
||||
else if (message[1] == 'list_method') {
|
||||
var listObject = realm.objects(message[2])[0];
|
||||
var list = listObject[message[3]];
|
||||
result = list[message[4]].apply(list, message.slice(5));
|
||||
}
|
||||
else {
|
||||
throw new Error('Unknown realm method: ' + message[1]);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue