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.

Add callback to 'end' event handler

See original GitHub issue

Currently, it’s not possible to perform asynchronous operations within the end event and manipulate the resulting CSS based on these operations. This causes a lot of problems since node.js and its ecosystem is primarily asynchronous. To mitigate this problem, I propose that a callback should be added like we once had in versions prior to 0.40.0, e.g.:

stylus.on('end', function (css, callback) {
    someAsynchronousOperation(function (err, result) {
        if (err) callback(err);
        callback(null, result); 
    });
});

In case of multiple listeners, it could move to the next listener after the callback has been triggered to not cause any issues with asynchronous writes to the CSS.

Issue Analytics

  • State:open
  • Created 9 years ago
  • Reactions:3
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

25reactions
FezVrastacommented, Aug 27, 2016

Any update on this? it’s quite important to make PostCSS work with Stylus 😕

0reactions
sugarshincommented, Jul 12, 2016

👍

Read more comments on GitHub >

github_iconTop Results From Across the Web

Defining behavior with event callbacks and listeners
You can do this by defining event-handling callback functions as part of the definition of the control or window. To respond to a...
Read more >
EventTarget.addEventListener() - Web APIs | MDN
The event listener can be specified as either a callback function or an object whose handleEvent() method serves as the callback function. The ......
Read more >
Add callback to .addEventListener - javascript - Stack Overflow
I looked at bind, but that seems to focus on controlling which "this" gets sent over to the event listener function. Any other...
Read more >
bokeh.events — Bokeh 3.0.3 Documentation
Represent granular events that can be used to trigger callbacks. Bokeh documents and applications are capable of supporting various kinds of interactions.
Read more >
Homework: Event Handling with Event Listeners
We call the method addEventListener() on our form object to create the event listener. Just like with event handler properties, we target the ......
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