
Security News
Official Go SDK for MCP in Development, Stable Release Expected in August
The official Go SDK for the Model Context Protocol is in development, with a stable, production-ready release expected by August 2025.
backbone.statemanager
Advanced tools
Simple, powerful state management for Backbone.js
Backbone.StateManager is a module for Backbone.js that adds the ability to easily
manage and utilize states in any size JavaScript application. It can be used as
a stand alone object or in conjunction with a target object through its addStateManager
method.
Backbone.StateManager currently has the following dependencies:
Backbone.StateManager is written in CoffeeScript. You can download the raw source code from the "src" folder or download the JavaScript build in the main directory.
The latest stable releases can be found at the links:
Development: backbone.statemanager.js
Production: backbone.statemanager.min.js
Backbone.StateManager constructor takes two arguments, a state object and an options object, but neither is required. Passed in states will be automatically added and the options are set as an instance property.
stateManager = new Backbone.StateManager
# or
states =
foo :
enter : -> console.log 'enter bar'
exit : -> console.log 'exit foo'
bar :
enter : -> console.log 'enter bar'
exit : -> console.log 'exit bar'
stateManager = new Backbone.StateManager states
A state is intended to be as modular as possible, so each state is expected to contain enter
and exit
methods that are used when entering or leaving that state. A state definition can also have a transitions property that contains several methods to be used when moving between specified states.
{
enter : -> console.log 'enter'
exit : -> console.log 'exit'
transitions :
'onBeforeExitTo:anotherState' : -> # method to be called before exit to `anotherState`
'onExitTo:anotherState' : -> # method to be called on exit to `anotherState`
'onBeforeEnterFrom:anotherState' : -> # method to be called before entering from `anotherState`
'onEnterFrom:anotherState' : -> # method to be called on entering from `anotherState`
}
Transitions are used to execute additional functionality when moving between specified states. There are 4 types of transitions that Backbone.StateManager will defaultly look for: onBeforeExitTo
, onExitTo
, onBeforeEnterFrom
, and onEnterFrom
. Each transition is a key value pair, where the value is a method and the key defines the transition type and the specified state (e.g. onEnterFrom:specifiedState
).
New states can be added individually using addState
and passing the name of the state and a state object as defined above.
stateManager.addState name, definition
A state is triggered using triggerState
and passing the name of the state and options. If the requested state is already the currentState, no methods will be executed. This can be overriden by passing in the option reEnter : true
to the method.
stateManager.triggerState name, options
A states can be added using removeState
and passing in the name of the state.
stateManager.removeState name
StateManager provides an easy method to painlessly add a StateManager to any object. StateManager.addStateManager
takes a target object and an optional set of options, reads in any states defined on the target, and creates a new StateManager. It also sets a number of methods on target, including triggerState
, getCurrentState
, and a reference to the StateManager at target.stateManager
.
View = Backbone.View.extend
states :
foo :
enter : -> console.log 'enter bar'
exit : -> console.log 'exit foo'
transitions :
'onExitTo:bar' : -> 'just exited and bar is about to be entered'
bar :
enter : -> console.log 'enter bar'
exit : -> console.log 'exit bar'
initialize : -> Backbone.StateManager.addStateManager @
Note: Similar to Backbone.js' defaults
attribute, the states
object will be shared among all instances of this state-managed view. Instead, define states
as a function that returns an object consisting of your state definitions.
# From the project's dir
npm install && bower install
This project uses Gulp.js for it's build tool
To build:
gulp build
To run tests:
gulp test
To build, run tests, and watch for changes:
gulp
FAQs
Simple, powerful state management for Backbone.js
We found that backbone.statemanager demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
The official Go SDK for the Model Context Protocol is in development, with a stable, production-ready release expected by August 2025.
Security News
New research reveals that LLMs often fake understanding, passing benchmarks but failing to apply concepts or stay internally consistent.
Security News
Django has updated its security policies to reject AI-generated vulnerability reports that include fabricated or unverifiable content.