Callbacks will now receive the running job as 'self' #9
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Howdy!
While playing around with luajob, I found it a little strange that the callbacks do not seem to give access to the job object itself. While this is probably fine for piping output from an external process into a buffer, it makes it somewhat awkward to store & retrieve the result of the job.
For example, in the snippet in the README that uses 'git branch' to retrieve the current branch, it eventually needs to push that result into some kind of global scope via nvim_*_set_var(). It would be a lot cleaner if the result was simply stored back onto the job object itself, like so:
Anyway, this little patch injects "self" into the callbacks
on_stdout
,on_stderr
, andon_exit
.