Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

flow-stoplight

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

flow-stoplight

A simple flow control mechanism.

  • 1.0.0
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
38K
increased by14.58%
Maintainers
1
Weekly downloads
 
Created
Source

Stoplight

A simple flow control mechanism.

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

Starts stopped.

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.


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
  })
}

FAQs

Package last updated on 08 Feb 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc