postcss / postcss-simple-vars

PostCSS plugin for Sass-like variables
MIT License
419 stars 35 forks source link

Make variable resolving asynchronous #44

Closed rexxars closed 8 years ago

rexxars commented 8 years ago

This PR adds support for asynchronously resolving the variable values. I had a pretty particular case where I need this, but I suppose it may be helpful to others as well. Let me know if you want anything changed - I couldn't quite make out the code style.

ai commented 8 years ago

Could you change a spec changes (removing a brackets) and this feature?

rexxars commented 8 years ago

I didn't quite catch that... Could you elaborate?

I removed the curly brackets from the tests because the operation is now async, and the run method now returns a promise, which makes ava automatically finish the tests once the promise is resolved or rejected.

ai commented 8 years ago

Ouh :(.

BTW, what is your user case?

rexxars commented 8 years ago

We are building a dynamic role-based plugin system for one of our products, where plugins are able to provide variables for styling the application. When resolving the final values of the variables, we need to resolve all the plugins that fulfill a given role, load the plugins and merge the results of all these together. The process involves touching the filesystem quite a lot, which is why doing it asynchronously makes sense.

ai commented 8 years ago

I afraid that it makes plugin to complicated. Maybe you should do it in separated plugin?