Task extended
Run a node script in a separate process.
Used by the fuzzy-finder and find in project.
For a real-world example, see the scan-handler and the instantiation of the task.
Examples
In your package code:
require 'atom'task = Taskonce '/path/to/task-file.coffee'parameter1parameter2->consolelog 'task has finished'taskon 'some-event-from-the-task'consolelog datasomeString # prints 'yep this is it'
In '/path/to/task-file.coffee'
:
=# Indicates that this task will be async.# Call the `callback` to finish the taskcallback = @asyncemit'some-event-from-the-task'someString: 'yep this is it'callback
Methods
::start(args, [callback])
Starts the task.
Throws an error if this task has already been terminated or if sending a message to the child process fails.
Argument | Description |
---|---|
args |
The arguments to pass to the function exported by this task's script. |
callback() |
optional
A Function to call when the task completes. |
::send(message)
Send message to the task.
Throws an error if this task has already been terminated or if sending a message to the child process fails.
Argument | Description |
---|---|
message |
The message to send to the task. |
::on(eventName, callback)
Call a function when an event is emitted by the child process
Argument | Description |
---|---|
eventName |
The String name of the event to handle. |
callback() |
The Function to call when the event is emitted. |
Return values |
---|
Returns a Disposable that can be used to stop listening for the event. |
::terminate()
Forcefully stop the running task.
No more events are emitted once this method is called.
::cancel()
Cancel the running task and emit an event if it was canceled.
Return values |
---|
Returns a Boolean indicating whether the task was terminated. |