🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

angular-viewstate

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

angular-viewstate

A state machine suited for angular 1.x digest

0.0.1
latest
Source
npm
Version published
Weekly downloads
1
-50%
Maintainers
1
Weekly downloads
 
Created
Source

#angular-viewstate

A state machine suited for angular 1.x digest

Installation

Requires browserify or similar npm-based build system.

In the command line:

npm install angular-viewstate --save

In your angular composition:

angular.module('myModule', [])
  .factory('viewState', require('angular-viewstate');

Usage

function controller($scope) {

  // setup states
  var state = require('angular-viewstate)
    .state('LOADING')
    .state('READY')
    .state('SAVING')
    .flag('isLoading').expression('LOADING')
    .flag('isReady').expression('!LOADING').delay(10)
    .flag('isIdle').expression('READY')
    .finalise($scope);
    
  // change state
  state.go.LOADING()
  loadSomething()
    .then(...)
    .finally(state.go.READY);
}

Every state() that is defined will produce a method on the go object.

Every flag expression() is an angular $watch expression where any identifier is replaced by (viewState === "<identifier>"). When finalise() is called the watchers are installed on the given scope.

Keywords

statemachine

FAQs

Package last updated on 18 May 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