How to use the realm.Sync function in realm

To help you get started, we’ve selected a few realm examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github realm / realm-js / tests / js / user-tests.js View on Github external
testLogout() {
    return Realm.Sync.User.login('http://127.0.0.1:9080', Realm.Sync.Credentials.anonymous()).then((user) => {
      assertIsUser(user);

      assertIsSameUser(user, Realm.Sync.User.current);
      user.logout();

      // Is now logged out.
      TestCase.assertUndefined(Realm.Sync.User.current);

      // Can we open a realm with the registered user?
      TestCase.assertThrows(() => new Realm({sync: {user: user, url: 'realm://127.0.0.1:9080/~/test'}}));
    });
  },
github realm / realm-js / tests / js / index.js View on Github external
// FIXME: Permission tests currently fail in react native
        TESTS.PermissionTests = require('./permission-tests');
        node_require('./adapter-tests');
        node_require('./notifier-tests');
    }
}

// If on node, run the async tests
if (isNodeProcess && process.platform !== 'win32') {
    TESTS.AsyncTests = node_require('./async-tests');
}

if (global.enableSyncTests) {
    // Ensure that the sync manager is initialized as initializing it
    // after calling clearTestState() doesn't work
    Realm.Sync.User.all;
}

var SPECIAL_METHODS = {
    beforeEach: true,
    afterEach: true,
};

exports.getTestNames = function () {
    var testNames = {};

    for (var suiteName in TESTS) {
        var testSuite = TESTS[suiteName];

        testNames[suiteName] = Object.keys(testSuite).filter(function (testName) {
            return !(testName in SPECIAL_METHODS) && typeof testSuite[testName] == 'function';
        });
github realm / realm-js / tests / js / subscription-tests.js View on Github external
function pendingOrComplete(state) {
    return state === Realm.Sync.SubscriptionState.Pending || state === Realm.Sync.SubscriptionState.Complete;
}
github realm / react-realm-context / src / test-utils / with-ros.ts View on Github external
createTestUser: () => {
    return Realm.Sync.User.login(
      REALM_OBJECT_SERVER_URL,
      Realm.Sync.Credentials.nickname(`react-realm-context-tests-${uuid()}`),
    );
  },
};
github realm / realm-js / tests / js / user-tests.js View on Github external
function assertIsUser(user, isAdmin) {
  TestCase.assertType(user, 'object');
  TestCase.assertType(user.token, 'string');
  TestCase.assertType(user.identity, 'string');
  TestCase.assertInstanceOf(user, Realm.Sync.User);
  if (isAdmin !== undefined) {
    TestCase.assertEqual(user.isAdmin, isAdmin);
  }
}
github realm / react-realm-context / src / test-utils / with-ros.ts View on Github external
createTestUser: () => {
    return Realm.Sync.User.login(
      REALM_OBJECT_SERVER_URL,
      Realm.Sync.Credentials.nickname(`react-realm-context-tests-${uuid()}`),
    );
  },
};
github realm / realm-scanner / Server / index.js View on Github external
}
                        scan.faceDetectionResult = faceDetectionResult;
                        scan.status = kFaceDetectionResultReady;
                    });
                }
            });
          }
        }
    }
};

//Create the admin user
var admin_user = Realm.Sync.User.adminUser(REALM_ADMIN_TOKEN, SERVER_URL);

//Callback on Realm changes
Realm.Sync.addListener(SERVER_URL, admin_user, NOTIFIER_PATH, 'change', change_notification_callback);

console.log('Listening for Realm changes across: ' + NOTIFIER_PATH);