Skip to content

Instantly share code, notes, and snippets.

@PyYoshi
Created June 6, 2016 10:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PyYoshi/58ac9a2891bb1ceed1e7bdd9b2bd63c0 to your computer and use it in GitHub Desktop.
Save PyYoshi/58ac9a2891bb1ceed1e7bdd9b2bd63c0 to your computer and use it in GitHub Desktop.
function sleep() {
var ms = arguments.length <= 0 || arguments[0] === undefined ? 0 : arguments[0];
return new Promise(
function (r) {
return setTimeout(r, ms);
}
);
}
var writeTransactionCreateCarAndPerson3 = function writeTransactionCreateCarAndPerson3() {
var realm = new _realm2.default({ schema: [Car, Person] });
realm.write(function _callee() {
return regeneratorRuntime.async(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
realm.create(
'Car',
{
id: 1,
make: 'Honda',
model: 'Civic',
miles: 1000
},
true
);
_context.next = 3;
return regeneratorRuntime.awrap(
sleep(300)
);
case 3:
realm.create(
'Person',
{
id: 1,
name: 'Charlie'
},
true
);
case 4:
case 'end': return _context.stop();
}
}
}, null, _this);
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment