question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Please provide asynchronous query/update API.

See original GitHub issue

Currently, the API to query(realm.objects('table')) or update(realm.create) documents is synchronous, this will lead to the javascript thread to be blocked.

It is inefficient if the table is big enough.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:7
  • Comments:26 (11 by maintainers)

github_iconTop GitHub Comments

2reactions
markhomokicommented, Jan 24, 2018

Thank you guys for your help. Now I could increase the performance a bit. Now it takes 20seconds less than before thanks to deleting the Realm file and then create a new instance.

I had to update the Realm config file. The only issue with this that I have to call getRealmInstance every time I want to access to the instance after the resetRealm function called because import loses the instance. Thanks again and sorry for messing up this issue, as at the end it is not really related to the async API.

const createRealm = () => new Realm(realmConfig);
let realm = createRealm();

const resetRealm = () => {
	realm.close();
	Realm.deleteFile(realmConfig);
	realm = createRealm();
};

const getRealmInstance = () => realm;
const realmInstance = getRealmInstance();

export { getRealmInstance, resetRealm };
export default realmInstance;
2reactions
allenhsucommented, Dec 5, 2017

We’re using realm-js for a new react native project, we haven’t met any practical issue yet, but we’re also looking for an async version of query APIs.

I noticed in rpc.js it’s opening a sync XMLHttpRequest. Although it’s a local RPC call, but it’s still a network request rather than code execution. IMPO, it’ll be nice to make async request and provide Promise based query APIs. It’s also more intuitive to me since fetching data from server are all async and returning Promises.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Enable Asynchronous API - Salesforce Help
To activate the Asynchronous API feature, please take the following steps: · Have a system administrator to log a Case with Salesforce Support....
Read more >
Update an Asynchronous Endpoint - Amazon SageMaker
Update an asynchronous endpoint with the UpdateEndpoint API. When you update an endpoint, SageMaker first provisions and switches to the new endpoint ...
Read more >
Supermetrics API - Async queries
By default, a Supermetrics API query is a synchronous request, meaning the HTTP request waits until the query has finished running. This is ......
Read more >
Synchronous and asynchronous requests - Web APIs | MDN
XMLHttpRequest supports both synchronous and asynchronous communications. In general, however, asynchronous requests should be preferred to ...
Read more >
Write asynchronous DAO queries - Android Developers
One-shot write queries that insert, update, or delete data in the database. One-shot read queries that read data from your database only ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found