GithubHelp home page GithubHelp logo

dsr's Introduction

Deep State Redirect

DSR for UI-Router 1.0  Build Status

With Deep State Redirect, a parent state remembers whatever child state was last activated. When the user directly reactivates the parent state, they are redirected to the nested state (which was previously activated).

Overview and Use Case

Deep State Redirect (DSR) is a marker you can add to a state definition.

When a child state of the DSR marked state is activated, UI-Router Extras remembers the child and its parameters. The most-recently-activate child is remembered no matter where the user navigates in the state tree. When the DSR marked state is directly activated, UI-Router Extras will redirect to the remembered child state and parameters.

One use case for DSR is a tabbed application. Each tab might contain an application module. Each tabs' state is marked as deepStateRedirect. When the user navigates into the tab, and drills down to a substate, DSR will remember the substate. The user can then navigate to other tabs (or somewhere else completely). When they click the original tab again, it will transition to the remembered ehild state and parameters of that tab, making it appear that the tab was never destructed.

Deep State Redirect can be used with StickyStates, or on its own. If used with a Sticky State, the states will be reactivated, and the DOM will be unchanged (as opposed to the states being re-entered and controllers re-initialized)

Using

See: http://christopherthielen.github.io/ui-router-extras/#/dsr

TODO: Move docs here

Using a custom DataStore

By default DSR stores the most recent redirects in memory. Alternatively, you can store the redirects in Local Storage using LocalStorageDataStore or create your own DataStore.

When registering the DSRPlugin, pass an options object with a dataStore property, i.e.:

router.plugin(DSRPlugin, { dataStore: new LocalStorageDataStore() });

Example Builds

The /examples directory contains example setups for:

  • Angular-CLI
  • AngularJS + bower + script tags
  • AngularJS + npm + script tags
  • AngularJS + webpack
  • Create-React-App

dsr's People

Contributors

christopherthielen avatar daneget avatar davidecordella avatar dependabot-preview[bot] avatar dependabot-support avatar dependabot[bot] avatar greenkeeper[bot] 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.