Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Realm 领域函数-我可以在changeEvent中打开其他领域吗_Realm_Realm Mobile Platform - Fatal编程技术网

Realm 领域函数-我可以在changeEvent中打开其他领域吗

Realm 领域函数-我可以在changeEvent中打开其他领域吗,realm,realm-mobile-platform,Realm,Realm Mobile Platform,我想在changeEvent调用中打开另一个域,将信息复制到其中。就像有追随者一样,若我添加了新帖子,它也应该被复制到追随者表中。打开同步域没有多大帮助,看起来它里面没有数据您应该尝试realm.openAsync(),这将确保域在返回回调之前同步。但是,这并不能确保在第一次启动处理程序之前同步领域 下面是一个简单的例子: const Realm = require('realm'); const server_url = 'realm://localhost:9080'; con

我想在changeEvent调用中打开另一个域,将信息复制到其中。就像有追随者一样,若我添加了新帖子,它也应该被复制到追随者表中。打开同步域没有多大帮助,看起来它里面没有数据

您应该尝试
realm.openAsync()
,这将确保域在返回回调之前同步。但是,这并不能确保在第一次启动处理程序之前同步领域

下面是一个简单的例子:

const Realm = require('realm');
const server_url        = 'realm://localhost:9080';
const REALM_ADMIN_TOKEN = "insert token here";
const adminUser = Realm.Sync.User.adminUser(REALM_ADMIN_TOKEN);

console.log("Opening admin realm");
var adminRealm = null;
Realm.openAsync({sync: {user: adminUser, url: server_url + '/some-realm'}, readOnly: true}, (realm) => {
  adminRealm = realm;
  console.log("Admin Realm loaded");
});

// your handler code here.