# flow-stoplight

> A simple flow control mechanism.

Latest version **1.0.0** (published 2016-02-08) · ISC license · 0 weekly downloads

## Install

```sh
npm install flow-stoplight
pnpm add flow-stoplight
yarn add flow-stoplight
bun add flow-stoplight
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2016-02-08 |
| First published | 2016-02-08 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | kumavis |

## Links

- npm: https://www.npmjs.com/package/flow-stoplight
- npm.io page: https://npm.io/package/flow-stoplight

## Recent versions

- 1.0.0 (latest) — 2016-02-08

## README

### Stoplight

A simple flow control mechanism.

Has two modes: "go" and "stop".

Starts stopped.

```js
var stoplight = new Stoplight()

stoplight.await(function(){
  // this will called when the stoplight is set to "go"
  // if its already "go", it will be called on the next frame
})

// starts stopped
stoplight.go()
```


### Example

Here is a class that has some async intialization process,
but can have its asynchronous method called immediately w/o breaking.

```js

function MyClass() {
  var self = this
  self._stoplight = new Stoplight()
  asyncInitialization(function(){
    self._stoplight.go()
  })
}

MyClass.prototype.asyncMethod = function(cb){
  var self = this
  self._stoplight.await(function(){
    // handle the method here and you can be sure that
    // the async initialization has finished
  })
}
```

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