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.

How to trigger sync and async imports

See original GitHub issue

How does less decide to call loadFile or loadFileSync of the current fileManager? According to this code it requires an isSync-parameter to be set. But a short search for a call to getFileManager reveals that this option is only used by lib/less/functions/data-uri.js.

Is it possible to set this option explicitly when calling render()?

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Comments:27 (18 by maintainers)

github_iconTop GitHub Comments

10reactions
ChiriVulpescommented, Aug 2, 2015

Is there a renderSync yet? If not, is there a workaround for a synchronous render?

Edit: Nvm. For any future person who stumbles upon this, this is what I did:

less.renderSync = function (input, options) {
    if (!options || typeof options != "object") options = {};
    options.sync = true;
    var css;
    this.render(input, options, function (err, result) {
        if (err) throw err;
        css = result.css;
    });
    return css;
};
5reactions
jhnnscommented, Jan 3, 2015

Cool!

There is just one problem: It is very unusual to do something synchronously while accepting a callback (as the render-function does). You’re suggesting a sync-option like this:

less.render(
    input,
    { ... sync: true ... },
    function (err, result) {
    }
);

?

Imho it’s weird to have the callback being called synchronously. I’d expect an api like this:

// async
less.render(input, option, callback);

// sync
var result = less.renderSync(input, option);
Read more comments on GitHub >

github_iconTop Results From Across the Web

Convert import() to synchronous - javascript - Stack Overflow
I'm trying to convert all of my node require() s into the import() statements, however, those are async and I'm having a bit...
Read more >
Synchronous and asynchronous import sets - ServiceNow
An import set with a Mode of Synchronous will transform the data as soon as it is inserted (provided that the transform map...
Read more >
Synchronous and Asynchronous Automations - What is jestor?
Synchronous and asynchronous automations are triggers that either run in sync or out of sync with the user's actions.
Read more >
How To Handle Async Data Loading, Lazy Loading, and Code ...
Step 1 — Loading Asynchronous Data with useEffect. In this step, you'll use the useEffect Hook to load asynchronous data into a sample ......
Read more >
Designing Libraries for Async and Sync I/O
Don't want API differences between async and sync or to maintain two code-bases of similar code. Properties and constructors must be synchronous ......
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