# @koax/fork

> Koax support for non blocking async calls.

Latest version **0.3.1** (published 2016-03-03) · MIT license · 0 weekly downloads

## Install

```sh
npm install @koax/fork
pnpm add @koax/fork
yarn add @koax/fork
bun add @koax/fork
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.3.1 |
| Published | 2016-03-03 |
| First published | 2016-02-12 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 6 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | koax |

## Links

- npm: https://www.npmjs.com/package/@koax/fork
- Repository: https://github.com/koaxjs/fork
- Homepage: https://github.com/koaxjs/fork#readme
- Issues: https://github.com/koaxjs/fork/issues
- npm.io page: https://npm.io/package/@koax/fork

## Dependencies (6)

- [@f/channel](https://npm.io/package/@f/channel.md) ^1.0.0
- [@koax/boot](https://npm.io/package/@koax/boot.md) ^1.0.0
- [@f/is-function](https://npm.io/package/@f/is-function.md) ^1.1.1
- [@f/is-iterator](https://npm.io/package/@f/is-iterator.md) ^1.0.1
- [@f/is-generator](https://npm.io/package/@f/is-generator.md) ^1.3.2
- [@f/defer-promise](https://npm.io/package/@f/defer-promise.md) ^1.0.0

## Recent versions

- 0.3.1 (latest) — 2016-03-03
- 0.3.0 — 2016-02-25
- 0.2.0 — 2016-02-13
- 0.1.4 — 2016-02-13
- 0.1.3 — 2016-02-12
- 0.1.2 — 2016-02-12
- 0.1.1 — 2016-02-12

## README

# fork

[![Build status][travis-image]][travis-url]
[![Git tag][git-image]][git-url]
[![NPM version][npm-image]][npm-url]
[![Code style][standard-image]][standard-url]

Koax support for non blocking async calls. (Included in koax)

## Installation

    $ npm install @koax/fork

## Usage

```js
import koax, {fork, join, delay} from 'koax'

let dispatch = koax()

function * child () {
  yield delay(5)
  return 'foo'
}

dispatch(function * () {
  const task = yield fork(child)

  // do some things

  yield join(task) // => 'foo'

})
```

## API

### fork(fn)
Action creator.

- `fn` - function, generator, or iterator to fork

**Returns:** a task

### join(task)
Action creator.

- `task` - task to block on

**Returns:** result of task

### cancel(task)
Action creator. Throws error in running task with message: 'TaskCanceled'.

- `task` - task to cancel

### taskRunner(dispatch)
Runs tasks. Used internally by koax.

- `dispatch` - dispatch function

**Returns:** `dispatch`

### task.isRunning()

**Returns:** whether task is running

### task.result()

**Returns:** the result of the task

### task.error()

**Returns:** the error thrown by the task

###task.cancel()
Cancels task

## License

MIT

[travis-image]: https://img.shields.io/travis/koaxjs/fork.svg?style=flat-square
[travis-url]: https://travis-ci.org/koaxjs/fork
[git-image]: https://img.shields.io/github/tag/koaxjs/fork.svg
[git-url]: https://github.com/koaxjs/fork
[standard-image]: https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat
[standard-url]: https://github.com/feross/standard
[npm-image]: https://img.shields.io/npm/v/@koax/fork.svg?style=flat-square
[npm-url]: https://npmjs.org/package/@koax/fork

---
_Source: https://npm.io/package/@koax/fork · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
