UNPKG

@peter.naydenov/route-emitter

Version:

Changes in URL are converted in events according routes definition list

22 lines (16 loc) 605 B
function getCurrentAddress ( dependencies, state ) { /** * @function getCurrentAddress * @description Returns the name of the current address and the parsed data * @returns {array} [ addressName, data ] * */ return function getCurrentAddress () { const { lastAddress, lastLocation, routes } = state , { pattern } = lastAddress ? routes[lastAddress] : { pattern: 'null' } ; let data = pattern.match ( lastLocation ) return [ state.lastAddress, data ] }} // getCurrentAddress func. export default getCurrentAddress