Socket
Socket
Sign inDemoInstall

ember-route-history

Package Overview
Dependencies
220
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    ember-route-history

This is an Ember-CLI addon. It provides a service which keeps an history of the visited routes. You will be able to know what is the current route, and what was the previously visited routes.


Version published
Weekly downloads
160
increased by42.86%
Maintainers
1
Install size
13.8 MB
Created
Weekly downloads
 

Readme

Source

Ember-route-history Build Status

This is an Ember-CLI addon. It provides a service which keeps an history of the visited routes. You will be able to know what is the current route, and what was the previously visited routes.

Installation

Using ember-cli:

ember install ember-route-history

Usage

By default, the service is injected into all routes of your application. You can also inject it in any controllers, components or other services.

You need to extend the RouteHistoryMixin in the routes you would like to keep an history of. If you don't use this mixin in a certain route, it won't be tracked.

If you don't want to add this mixin for all your routes, you can simply create a base route that will extend this mixin, then you can extend your base route on all the routes of your application.

import Ember from 'ember';
import RouteHistoryMixin from 'ember-route-history/mixins/routes/route-history';

export default Ember.Route.extend(RouteHistoryMixin, {
    /* Your code here */
});

To use it, in a component for example:

export default Ember.Component.extend({
    routeHistory: Ember.inject.service(),

    onInsert: Ember.on('didInsertElement', function () {
        const currentRouteName = this.get('routeHistory.current'); // Returns the current route name.
        const previousRouteName = this.get('routeHistory.previous'); // Returns the name of the previously visited route.
        const fullRouteHistory = this.get('routeHistory.history'); // Returns an array of route names.
    }
});

By default, only 10 items are saved in the history. You can increase the size of the stack by setting maxHistoryLength.

this.set('routeHistory.maxHistoryLength', 50);

Keywords

FAQs

Last updated on 21 Dec 2017

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc