paulmillr / read-components

Read bower and component(1) components
28 stars 9 forks source link

Why async? #17

Closed jeron-diovis closed 10 years ago

jeron-diovis commented 10 years ago

Why not to to read components synchronously (or at least allow it as some option)? While provided functionality is so useful - sometimes it can't be used together with third-party tools. Brunch was designed to work with this reader asynchronously. Grunt gives us 'this.async()' inside task, and it helps. But what about something more specific? For example, I want to compose modules list for LMD builder. All I need is to specify module.exports field in config file - but there is no way to wait until filelist will be read.

So can this tool be upgraded to be synchronous? Or, maybe, I just don't know how to return async result from module (without exporting functions) - then, could you give me some advice about this?

paulmillr commented 10 years ago

async — because IO (filesystem).

it's very easy and idiomatic in node.js to write async code. Sorry, read-c won't become async - we don't want more complexity.

paulmillr commented 10 years ago

I just don't know how to return async result from module (without exporting functions)

There is no way.

forivall commented 10 years ago

Look at using node-fibers and making an adapter for sync behaviour.