Closed marcooliveira closed 11 years ago
By the way, forgot to mention, the spec is looking promising ;)
No worries about the long post!
Thanks @tkellen for considering our points. Still there's a problem with the emitter being part of the task object itself. If someone tries to use a task in parallel like this:
var mincss = require('mincss-task');
mincss.run({
files: {
'dist/main.css': 'src/main.css'
}
}).on('log', function () {
console.log('something was logged when running min of main.css');
});
// And afterwards..
mincss.run({
files: {
'dist/panel.css': 'src/panel.css'
}
}).on('log', function () {
console.log('something was logged when running min of panel.css');
});
Since the emitter is common to the object itself, log events and others will collide when running the same task in parallel. This will make parallel support at the task runner somewhat difficult, specially if we got more important events that might carry data.
Like we said in the post above, this could be solved with an emitter being returned that would have start
, end
, log.*
and maybe others (data
for piping?).
Awesome! Great to see that we see eye to eye in a lot of topics.
@tkellen
- The spec now requires that run always return a promise.
Great to see this consistency. But consider the notes below.
@marcooliveira / @satazor:
Why not simply rely on the already in spec emitter, and specify a set of standard events (something like start and end, possibly a few more), that will provide feedback about what's happening? Also, a new emitter should always be created and returned when invoking run, so there is no collision between re-used tasks. (imagine using the same task twice, in parallel, would cause a conflict in the listeners, if there weren't two emitters).
I'm just wondering what's the reasoning behind using promises instead of the emitter. I see that the idea of using emitters or promises has been kicked around in other issues, but just wondering why the emitter did not stick. At first glance, seems like a powerful solution. /cc @millermedeiros @sindresorhus
I'm comfortable with the name node-task for now, but I see your point and will consider this.
Cool. If this is to happen, probably better sooner than latter, less hassle. Maybe move that into a separate issue, and have an open discussion about it? Ideas tend to get lost when we have brainstorm dumps like the one we did, and this issue now seems to be reduced to 2 open discussions :)
Final tiny note, maybe there should be a list of the task runners that are committed to contribute and support the spec? As for as I know, there is currently http://gruntjs.com/ and http://indigounited.com/automaton/
Bump.
Just updated the spec to include the task as an instance of an event emitter. We're still going with returned promises to indicate task completion, which will make more sense when the fileReader and fileWriter specs are up.
@tkellen I see that spec props are now attached to the prototype
. This is a good decision, since it will allow us to paralelize tasks without any problems.
Still I think you made a mistake. By doing:
var Task = module.exports = require('events').EventEmitter;
Task.prototype.bla = 'name'
We are modifying the EventEmitter protype directly. Shouldn't we use util.inherits or Object.create?
Just changed that, actually :)
Alright thanks! The spec is looking much more clean now.
:) Awesome! I'm closing this one for now. We're going to stick with node-task for the name. I'm looking forward to hearing your feedback on the fileReader/Writer additions of the spec.
(follow up from https://github.com/IndigoUnited/automaton/issues/49)
Here's a list of topics that me and @satazor sorted out, after analysing the current state of the spec:
⊄
symbol, even though they do not seem to belong to the original spec.run
method can currently provide feedback in multiple ways (sync AND promises)start
andend
, possibly a few more), that will provide feedback about what's happening? Also, a new emitter should always be created and returned when invokingrun
, so there is no collision between re-used tasks. (imagine using the same task twice, in parallel, would cause a conflict in the listeners, if there weren't two emitters).node-task
? The spec can potentially be implemented in any JavaScript environment, so there's no need to limit and put that label in the spec (maybejs-task
?).Looking forward to get some feedback on this. Sorry for the long post, just wanted to be meticulous.
Also, might be a good idea to exchange Skype/GTalk contacts, so we don't pollute the repository with raw ideas (also speeds up everything).