jpettersson/orangejuice — pull request #19 by javoire (2014-03-05 02:22:00+00:00)
Title: plugins need to be able to hook in later in the process!

So right now, orangejuice-livereload gets the OJ object freshly instantiated,
```
var oj = require('orangejuice'),
livereload = require('orangejuice-livereload'),
html2js = require('gulp-html2js');

livereload(oj);
...
```
which means it only get's the default values of things. User-specified things in ojfile hasn't yet been saved in the oj singleton etc.

The oj-livereload module would need to be initialized later to get the correct values from OJ. It looks like the earliest point it can be run would be on the first next tick:
```
// boot.js

process.nextTick(function(){
// like here.. !
OJ.run();
});
```
So I did a callback test which is triggered in the ```OJ.run()``` method the first time it's run, because I wanted to get ahold of the ```sourceFiles``` array and give it to livereload :)

It seems to work fine, but I don't know how and where it makes sense to put a callback like this in OJ really, I suppose it depends a lot on possible future plugins. In this specific case I needed to hook in after ojfile.js has been evaluated once, but I also needed to steal the sourceFiles array :)

Anyway, drop some comments on what you think would be best! Also if this functionality is even necessary, a user could probably just set the required settings for oj-livereload in ojfile as well.

And this is a [PR that shows how this looks from the orangejuice-livereload perspective](https://github.com/javoire/orangejuice-livereload/pull/6/files)