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

statetransition-mixin

Package Overview
Dependencies
Maintainers
1
Versions
80
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

statetransition-mixin

mixin to declare state transition methots like start & stop

  • 1.4.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
348
decreased by-45.79%
Maintainers
1
Weekly downloads
 
Created
Source

statetransition-mixin

npmsemantic-releaseBuild StatusCoverage StatusCode ClimateGitHub IssuesDependency StatusdevDependency Statusdocsdownloads

start stop

usage

for es6 classes to

const stm = require('statetranstion-mixin');

const actions = stm.prepareActions({
start: {
  stopped: {
    target: "running",
    during: "starting",
    timeout: 10
  }
},
stop: {
  running: {
    target: "stopped",
    during: "stopping",
    timeout: 5
  },
  starting: {
    target: "stopped",
    during: "stopping",
    timeout: 10
  }
}
});

class BaseClass {}

class StatefullClass extends stm.StateTransitionMixin(BaseClass, actions, 'stopped') {
_start() {
  return new Promise((f, r) => {
    setTimeout(() => {
      f(this)
    }, 10);
  });
}
}

stm.defineActionMethods(StatefullClass.prototype, actions);

myObject = new StatefullClass();

myObject.start().then( (o) => console.log('started == ${o.state}'));
console.log('starting == ${myObject.state}');

myObject.stop().then( (o) => console.log('stopped == ${o.state}'));
console.log('stopping == ${myObject.state}');

install

With npm do:

npm install statetransition-mixin

license

BSD-2-Clause

Keywords

FAQs

Package last updated on 31 Dec 2015

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