GithubHelp home page GithubHelp logo

play-coin-code / visualizer Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ui-router/visualizer

0.0 1.0 0.0 3.09 MB

UI-Router state visualizer and transition visualizer

License: MIT License

JavaScript 8.31% HTML 2.08% CSS 25.53% Shell 1.10% TypeScript 62.99%

visualizer's Introduction

UI-Router State Visualizer and Transition Visualizer

Try the Demo plunker

Image of Visualizer

What

Visualizes the state tree and transitions in UI-Router 1.0+.

This script augments your app with two components:

  1. State Visualizer: Your UI-Router state tree, showing the active state and its active ancestors (green nodes)

  2. Transition Visualizer: A list of each transition (from one state to another)

    • Color coded transition status (success/error/ignored/redirected)
    • Shows which states were retained during the transition, which were exited, and which were entered.
    • Shows parameter values
    • Shows resolve data

How

This script is distributed as a UMD module. There are two ways to add this to your application:

Using a script tag

  • Add a script tag to your HTML. The visualizer will be added to the window as window['ui-router-visualizer'].

    <script src="//unpkg.com/ui-router-visualizer@2"></script>
    
  • Create the visualizer:

    Angular 1

    Inject the $uiRouter router instance in a run block. Get the ui-router-visualizer off the window and pass it the router instance.

    Note: in ui-router 1.0.0-beta.2 and earlier, $uiRouter was named ng1UIRouter

    // inject the router instance by name
    app.run(function($uiRouter) {
     var vis = window['ui-router-visualizer'];
     vis.visualizer($uiRouter);
    });

    Angular 2

    Get the ui-router-visualizer off the window. Pass the router instance to the visualizer in the configure method of your UIRouterConfig.

    @Injectable()
    export class MyUIRouterConfig {
      constructor(router: UIRouter) {
        var vis = window['ui-router-visualizer'];
        vis.visualizer(router);
      }
    }
    
    ... 
    @NgModule({
      imports: [ UIRouterModule.forRoot({ configClass: MyUIRouterConfig }) ]
      ...

    React

    Bootstrap UI-Router by calling new UIRouterReact(); Pass the instance to the visualizer.

    var vis = window['ui-router-visualizer'];
    let router = new UIRouterReact();
    
    // register states here
    // ...
    
    vis.visualizer(router);
    router.start();

Using a module loader/bundler like webpack

  • Configure your bundler to load ui-router-visualizer. The visualizer will be available 'ui-router-visualizer'.

  • Create the visualizer:

    Angular 1

    Get the ui-router-visualizer using require or ES6 import. Inject the $uiRouter router instance in a run block. Provide the router instance to the visualizer.

    Note: in ui-router 1.0.0-beta.2 and earlier, $uiRouter was named ng1UIRouter

    import * as vis from 'ui-router-visualizer';
    // or: var vis = require('ui-router-visualizer');
    
    // inject the router instance by name
    app.run(function($uiRouter) {
     vis.visualizer($uiRouter);
    });

    Angular 2

    Get the ui-router-visualizer using require or ES6 import. Pass the router instance to the visualizer in the configure method of your UIRouterConfig.

    import * as vis from 'ui-router-visualizer';
    // or: var vis = require('ui-router-visualizer');
    
    @Injectable()
    export class MyUIRouterConfig {
      constructor(router: UIRouter) {
        vis.visualizer(router);
      }
    }
    
    ... 
    @NgModule({
      imports: [ UIRouterModule.forRoot({ configClass: MyUIRouterConfig }) ]
      ...

    React

    Get the ui-router-visualizer using require or ES6 import. Bootstrap UI-Router by calling new UIRouterReact(); Pass the instance to the visualizer.

    import * as vis from 'ui-router-visualizer';
    // or: var vis = require('ui-router-visualizer');
    
    let router = new UIRouterReact();
    
    // register states here
    // ...
    
    vis.visualizer(router);
    router.start();

visualizer's People

Contributors

christopherthielen avatar npmcdn-to-unpkg-bot avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.