Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add callback to 'end' event handler #1698

Open
andyjansson opened this issue Sep 18, 2014 · 6 comments
Open

Add callback to 'end' event handler #1698

andyjansson opened this issue Sep 18, 2014 · 6 comments

Comments

@andyjansson
Copy link

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.

@madeleineostoja
Copy link
Contributor

+1 this is a big problem for me with https://github.com/seaneking/poststylus, to process asynchronous PostCSS plugins we need to pass the result back to end in a callback.

@j-walker23
Copy link

Hi guys, is this still broken? I am trying to figure out a way to use stylus as es6 imports in a jspm systemjs app. Would this bug prevent me from doing that?
Thanks for any help!

@Panya
Copy link
Member

Panya commented Oct 13, 2015

@j-walker23 well, first of all it's not a bug. The issue is about support for asynchronous plugins inside end event handlers (so it's enhancement).

Hi guys, is this still broken? I am trying to figure out a way to use stylus as es6 imports in a jspm systemjs app. Would this bug prevent me from doing that?

Node.js version of Stylus heavily using fs for imports and some built-in functions and can't be used as-is for the browser. But we have special client branch for client-side usage. Information in this issue may help you acheive your goal.

@j-walker23
Copy link

Thanks for the help @Panya, i appreciate it!

@sugarshin
Copy link

👍

@FezVrasta
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants