Home / v2.1.2
Name Modified Size InfoDownloads / Week
Parent folder
README.md 2019-01-21 2.8 kB
v2.1.2 source code.tar.gz 2019-01-21 1.8 MB
v2.1.2 source code.zip 2019-01-21 1.8 MB
Totals: 3 Items   3.6 MB 0

⚡️ Parameters Destructuration (Breaking Change)

This is a breaking change about the way parameters are exposed in transitions and events methods. In order to be more flexible for future releases all parameters are now grouped in a single object that can be destructured to only get the informations needed. This means you don't need to bother anymore with the order of the parameters of with parameters you don't need. This also let us add as many entries in the object as we want in the future to expose more informations if needed for those methods without deprecating your code anymore.

Before v2.1.2:

:::js
// Events
H.on('NAVIGATE_IN', (to, location) => {});
H.on('NAVIGATE_OUT', (from, location) => {});
H.on('NAVIGATE_END', (from, to, location) => {});

// Transitions
class Transition extends Highway.Transition {
  in(from, to, done) {
    // [...]
  }

  out(from, done) {
    // [...]
  }
}

Now in v2.1.2:

:::js
// Events
// Use ES6 Object-Destructuring to filter parameters
H.on('NAVIGATE_IN', ({ to, trigger, location }) => {});
H.on('NAVIGATE_OUT', ({ from, trigger, location }) => {});
H.on('NAVIGATE_END', ({ from, to, trigger, location }) => {});

// Transitions
class Transition extends Highway.Transition {
  in({ from, to, trigger, done }) {
    // [...]
  }

  out({ from, trigger, done }) {
    // [...]
  }
}

🎉 Trigger Informations

This update is about informations on what has triggered the navigation process of Highway. You now have access to those informations inside the parameters of the transitions and events methods with the trigger keyword. This will return either:

  • The DOM Element
  • The popstate string when the back/forward browser's buttons trigger the navigation process
  • The script string when the redirect method of Highway.Core instance is called

Now in V2.1.2:

:::js
// Events
H.on('NAVIGATE_IN', ({ to, trigger, location }) => {});
H.on('NAVIGATE_OUT', ({ from, trigger, location }) => {});
H.on('NAVIGATE_END', ({ from, to, trigger, location }) => {});

// Transitions
class Transition extends Highway.Transition {
  in({ from, to, trigger, done }) {
    // [...]
  }

  out({ from, trigger, done }) {
    // [...]
  }
}

For further readings:

Source: README.md, updated 2019-01-21