jriecken / dependency-graph

A simple dependency graph for Node.js
http://jriecken.github.io/dependency-graph/
MIT License
333 stars 49 forks source link

order function which takes a name and returns [dependenciesOf(name)..., name, dependsOf(name)...] #5

Closed vjpr closed 9 years ago

vjpr commented 9 years ago

Similar to overallOrder, but just for a single dependency.

Use case: When used as an event trigger to run before and after hooks (which have interdependencies).

jriecken commented 9 years ago

Seems like the output in this case would be in a strange order - It would contain:

which seems backwards for the dependencies part of the result.

Can you give a concrete example?

vjpr commented 9 years ago

Sorry. I was mixing up dependencies and events in my head.

I want to do something like app.trigger('task') which would run its dependencies, and then trigger its dependants to run. Every task could run before, after or between other tasks.

The between tasks became difficult. I think what I actually need is to separate tasks and events. Tasks having dependencies. Events having before and after callbacks.