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

backbone-fsm

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

backbone-fsm

Finite-State Machine for Backbone views and models.

  • 0.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Backbone-FSM Build Status

Finite-State Machine for Backbone views and models. Browser and Node.js compatible.

Installation

Bower

bower install backbone-fsm

Old school

Include lib/backbone-fsm.js into your page.

Node.js

npm install backbone-fsm

Usage

Initialization

FSM comes with mixin method. You have to extend this during initialization.

var Foo = Backbone.View.extend({
	initialize: function () {
		FSM.mixin(this);
	}
});

Transitions

You can define transitions and defaultState:

var Foo = Backbone.View.extend({
	initialize: function () {
		FSM.mixin(this);
	},

	defaultState: 'firstState',

	transitions: {
		'transitionName': {
			from: 'firstState',
			to: 'secondState'
		}
	},

	onTransitionName: function (callback) {
		callback();
	}
});

To make a transition run transitionTo("secondState"). During transition:

  1. transition:start event is emited
  2. onTransitionName callback is called (if defined).
  3. transition:stop event is emited

Example

Backbone-FSM live example: http://jsfiddle.net/fragphace/Zc6Gx/

Tests

For server-side tests:

npm test

Browser tests can be found in test/browser.html. Tested under:

  • IE 7+
  • FF 15+
  • Chrome 22+

Development

  • Generate JS files - make coffee
  • Watch mode - make watch

Keywords

FAQs

Package last updated on 05 Feb 2014

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