packages/rebound-router/lib/rebound-router.js
function(){

    var routes = this.current ? (this.current.data.routes || {}) : {};
        routes[this._previousRoute] = '';

    // Unset Previous Application's Routes. For each route in the page app, remove
    // the handler from our route object and delete our referance to the route's callback
    _.each(routes, (value, key) => {
      var regExp = this._routeToRegExp(key).toString();
      Backbone.history.handlers = _.filter(Backbone.history.handlers, function(obj){
        return obj.route.toString() !== regExp;
      });
    });

    if(!this.current){ return void 0; }

    var oldPageName = this.current.__pageId;

    // Un-hook Event Bindings, Delete Objects
    this.current.data.deinitialize();

    // Now we no longer have a page installed.
    this.current = undefined;

    // Disable old css if it exists
    setTimeout(() => {
      if(this.status === ERROR){ return void 0; }
      document.getElementById(oldPageName + '-css').setAttribute('disabled', true);
    }, 500);

  }
function(){

    var routes = this.current ? (this.current.data.routes || {}) : {};
        routes[this._previousRoute] = '';

    // Unset Previous Application's Routes. For each route in the page app, remove
    // the handler from our route object and delete our referance to the route's callback
    _.each(routes, (value, key) => {
      var regExp = this._routeToRegExp(key).toString();
      Backbone.history.handlers = _.filter(Backbone.history.handlers, function(obj){
        return obj.route.toString() !== regExp;
      });
    });

    if(!this.current){ return void 0; }

    var oldPageName = this.current.__pageId;

    // Un-hook Event Bindings, Delete Objects
    this.current.data.deinitialize();

    // Now we no longer have a page installed.
    this.current = undefined;

    // Disable old css if it exists
    setTimeout(() => {
      if(this.status === ERROR){ return void 0; }
      document.getElementById(oldPageName + '-css').setAttribute('disabled', true);
    }, 500);

  }
function ( ) { var routes = this . current ? ( this . current . data . routes || { } ) : { } ; routes [ this . _previousRoute ] = '' ; // Unset Previous Application's Routes. For each route in the page app, remove // the handler from our route object and delete our referance to the route's callback _ . each ( routes , ( value , key ) => { var regExp = this . _routeToRegExp ( key ) . toString ( ) ; Backbone . history . handlers = _ . filter ( Backbone . history . handlers , function ( obj ) { return obj . route . toString ( ) !== regExp ; } ) ; } ) ; if ( ! this . current ) { return void 0 ; } var oldPageName = this . current . __pageId ; // Un-hook Event Bindings, Delete Objects this . current . data . deinitialize ( ) ; // Now we no longer have a page installed. this . current = undefined ; // Disable old css if it exists setTimeout ( ( ) => { if ( this . status === ERROR ) { return void 0 ; } document . getElementById ( oldPageName + '-css' ) . setAttribute ( 'disabled' , true ) ; } , 500 ) ; }
De-initializes the previous app before rendering a new app This way we can ensure that every new page starts with a clean slate This is crucial for scalability of a single page app.
De - initializes the previous app before rendering a new app This way we can ensure that every new page starts with a clean slate This is crucial for scalability of a single page app .