Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
N
next.js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alex
next.js
Commits
6db7101c
Commit
6db7101c
authored
Mar 08, 2017
by
Arunoda Susiripala
Committed by
Guillermo Rauch
Mar 08, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add beforeHistoryChange router event. (#1360)
parent
f9286f74
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
3 additions
and
1 deletion
+3
-1
index.js
lib/router/index.js
+1
-1
router.js
lib/router/router.js
+1
-0
readme.md
readme.md
+1
-0
No files found.
lib/router/index.js
View file @
6db7101c
...
@@ -15,7 +15,7 @@ const SingletonRouter = {
...
@@ -15,7 +15,7 @@ const SingletonRouter = {
// Create public properties and methods of the router in the SingletonRouter
// Create public properties and methods of the router in the SingletonRouter
const
propertyFields
=
[
'components'
,
'pathname'
,
'route'
,
'query'
]
const
propertyFields
=
[
'components'
,
'pathname'
,
'route'
,
'query'
]
const
coreMethodFields
=
[
'push'
,
'replace'
,
'reload'
,
'back'
,
'prefetch'
]
const
coreMethodFields
=
[
'push'
,
'replace'
,
'reload'
,
'back'
,
'prefetch'
]
const
routerEvents
=
[
'routeChangeStart'
,
'routeChangeComplete'
,
'routeChangeError'
]
const
routerEvents
=
[
'routeChangeStart'
,
'
beforeHistoryChange'
,
'
routeChangeComplete'
,
'routeChangeError'
]
propertyFields
.
forEach
((
field
)
=>
{
propertyFields
.
forEach
((
field
)
=>
{
// Here we need to use Object.defineProperty because, we need to return
// Here we need to use Object.defineProperty because, we need to return
...
...
lib/router/router.js
View file @
6db7101c
...
@@ -168,6 +168,7 @@ export default class Router extends EventEmitter {
...
@@ -168,6 +168,7 @@ export default class Router extends EventEmitter {
return
false
return
false
}
}
this
.
emit
(
'beforeHistoryChange'
,
as
)
this
.
changeState
(
method
,
url
,
as
,
options
)
this
.
changeState
(
method
,
url
,
as
,
options
)
const
hash
=
window
.
location
.
hash
.
substring
(
1
)
const
hash
=
window
.
location
.
hash
.
substring
(
1
)
...
...
readme.md
View file @
6db7101c
...
@@ -311,6 +311,7 @@ Here's a list of supported events:
...
@@ -311,6 +311,7 @@ Here's a list of supported events:
-
`routeChangeStart(url)`
- Fires when a route starts to change
-
`routeChangeStart(url)`
- Fires when a route starts to change
-
`routeChangeComplete(url)`
- Fires when a route changed completely
-
`routeChangeComplete(url)`
- Fires when a route changed completely
-
`routeChangeError(err, url)`
- Fires when there's an error when changing routes
-
`routeChangeError(err, url)`
- Fires when there's an error when changing routes
-
`beforeHistoryChange(url)`
- Fires just before changing the browser's history
-
`appUpdated(nextRoute)`
- Fires when switching pages and there's a new version of the app
-
`appUpdated(nextRoute)`
- Fires when switching pages and there's a new version of the app
> Here `url` is the URL shown in the browser. If you call `Router.push(url, as)` (or similar), then the value of `url` will be `as`.
> Here `url` is the URL shown in the browser. If you call `Router.push(url, as)` (or similar), then the value of `url` will be `as`.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment