Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
give your work an execution plan
JavaScript
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
jsdoc2md
lib
.gitignore
.jshintrc
README.md
package.json

README.md

view on npm npm module downloads per month Build Status Dependency Status

work

work.Job

A task defines a piece of work which needs doing now, or in the future. When you create a task you receive a promise for its result. Process the task using task.process().

Kind: static class of work

new Job(resolver, [options])

Param Type Description
resolver function | Array.<function()> the resolver function
[options] object an object containing optional values
[options.name] string a name string, useful for debugging
[options.data] object data used by the resolver function

job.promise : external:Promise

a promise for the completion of the task

Kind: instance property of Job

job.resolver : function | Array.<function()>

One or more functions to resolve the deferred. Each resolver function will be passed the deferred, which it must either resolve or reject.

Kind: instance property of Job

job.name : string

useful for debug output

Kind: instance property of Job

job.data : string

data for the task

Kind: instance property of Job

job.process()

Process the task - settled the deferred using the supplied resolver function(s)

Kind: instance method of Job

"resolved"

Emitted when a task resolves

Kind: event emitted by Job

"settled"

Emitted when a task is settled

Kind: event emitted by Job

"rejected"

Emitted when a task is rejected

Kind: event emitted by Job

Type Description
Error the rejection reason

"starting"

Emitted when a task starts

Kind: event emitted by Job

work.Queue

queue class for processing promises

Kind: static class of work

new Queue([options])

Param Type Default Description
[options] object
[options.maxConcurrent] number 1
[options.name] string useful for debugging

queue.name : string

useful for debugging

Kind: instance property of Queue

queue.queue : Array

the current task queue

Kind: instance property of Queue

queue.active : Array

The in-progress tasks

Kind: instance property of Queue

queue.maxConcurrent : number

when emptying, specifying the max number of tasks which may run simultaneously.

Kind: instance property of Queue
Default: 1

queue.length : number

queue length

Kind: instance property of Queue

queue.push(task) ⇒ Job

add a task to the queue

Kind: instance method of Queue

Param Type Description
task Job task instance

queue.shift() ⇒ Job

returns the next task in the queue and adds it to the active list.

Kind: instance method of Queue

queue.view(parentEl) ⇒ QueueView

place a view in the DOM under the specified parent element

Kind: instance method of Queue

Param Type Description
parentEl Element the parent element under which to place the view

queue.setSchedule(schedule)

Define a schedule for processing the queue.

Kind: instance method of Queue

Param Type Description
schedule function the schedule function to execute.. called in the context of this queue instance.

queue.clearSchedule()

Clears the schedule set by module:work#setSchedule.

Kind: instance method of Queue
Todo

  • refactor

queue.process()

process the queue - attempt to resolve each task.

Kind: instance method of Queue

"occupied"

Emitted at the moment a queue becomes occupied (has at least 1 task)

Kind: event emitted by Queue

"push"

Emitted when a task is added

Kind: event emitted by Queue

Type Description
Job the task that was pushed

"empty"

Emitted after the final task is taken off the queue for processing

Kind: event emitted by Queue

"shift"

Emitted when a task is shifted

Kind: event emitted by Queue

Type Description
Job the task that was pushed

"complete"

Emitted when the queue processing is complete

Kind: event emitted by Queue


© 2015 Lloyd Brookes <75pound@gmail.com>. Documented by jsdoc-to-markdown.

Something went wrong with that request. Please try again.