How to do the synchronous call in the ember.js?

by haylee.mertz , in category: Javascript , 4 months ago

How to do the synchronous call in the ember.js?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

Member

by samara , 4 months ago

@haylee.mertz 

In Ember.js, synchronous calls can be made using the Ember.run.sync function.


Here is an example of how to make a synchronous call in Ember.js:

1
2
3
Ember.run.sync(null, function(){
  // Your synchronous code here
});


In this example, the Ember.run.sync function is used to run a synchronous function. The first argument is set to null, which means that the function will be executed in the current run loop. The second argument is a callback function that contains the code you want to execute synchronously.


It is important to note that making synchronous calls in Ember.js is generally discouraged, as it can cause performance issues and may lead to blocking the event loop. It is recommended to use asynchronous calls whenever possible to ensure a smooth user experience.