client api for asynchronous task queue, using PouchDB for sync
JavaScript
Latest commit 5a33a30 Jan 16, 2017 @inator inator committed with gr2m chore(package): version placeholder (#39)
Permalink
Failed to load latest commit information.
lib
.gitignore refactor: adapt for new @hoodie/task-server (#36) Jan 14, 2017
.travis.yml
LICENSE
README.md refactor: adapt for new @hoodie/task-server (#36) Jan 14, 2017
index.js
package.json

README.md

hoodie-task-client

client api for asynchronous task queue, using PouchDB for sync

Build Status Coverage Status Dependency Status devDependency Status

Example

taskQueue('email').start({
  to: 'john@example.com',
  subject: 'Ohaj there',
  body: 'Hey John,\n\nhow are things?\n\n– Jane'
}).then(function (task) {
  alert('Email "' + task.subject + '" sent')
}).catch(function (error) {
  alert(error)
})

API

var taskQueue = new TaskQueue(userId, options)

mailQueue = taskQueue('mail')
taskQueue.on(eventName, handler)
taskQueue.one(eventName, handler)

mailQueue.start(attributes/*, options */)
mailQueue.abort(id/*, options */)
mailQueue.restart(id/*, options */)
mailQueue.on(eventName, handler)
mailQueue.one(eventName, handler)

Events, same for mailQueue.on / one and taskQueue.on / one

mailQueue.on('start', handleNewTask)
mailQueue.on('success', handleNewTaskSuccess)
mailQueue.on('error', handleNewTaskError)

Testing

Local setup

git clone https://github.com/hoodiehq/hoodie-task-client.git
cd hoodie-task-client
npm install

Run all tests and code style checks

npm test

Run all tests on file change

npm run test:watch

Run specific tests only

node tests/specs # run unit tests
node tests/specs/get-api # run .getApi() unit tests
node tests/integration/walkthrough # run walkthrough integration test
# PROTIP™ Pipe output through a [pretty reporter](https://www.npmjs.com/package/tape#pretty-reporters)

License

Apache 2.0