Skip to content

Commit

Permalink
Tidy notifier method signatures
Browse files Browse the repository at this point in the history
  • Loading branch information
domchristie committed Sep 25, 2023
1 parent b48b4a3 commit 1c629b4
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/core/session.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,8 @@ export class Session {
}
extendURLWithDeprecatedProperties(visit.location)
if (!visit.silent) {
this.notifyApplicationAfterVisitingLocation(visit.location, visit.action, visit.direction, visit.initiator)
const options = { action, direction, initiator } = visit

Check failure on line 195 in src/core/session.js

View workflow job for this annotation

GitHub Actions / build

'action' is not defined

Check failure on line 195 in src/core/session.js

View workflow job for this annotation

GitHub Actions / build

'direction' is not defined

Check failure on line 195 in src/core/session.js

View workflow job for this annotation

GitHub Actions / build

'initiator' is not defined

Check failure on line 195 in src/core/session.js

View workflow job for this annotation

GitHub Actions / build

'action' is not defined

Check failure on line 195 in src/core/session.js

View workflow job for this annotation

GitHub Actions / build

'direction' is not defined

Check failure on line 195 in src/core/session.js

View workflow job for this annotation

GitHub Actions / build

'initiator' is not defined
this.notifyApplicationAfterVisitingLocation(visit.location, options)
}
}

Expand Down Expand Up @@ -298,7 +299,7 @@ export class Session {
}

applicationAllowsVisitingLocation(location, options) {
const event = this.notifyApplicationBeforeVisitingLocation(location, options.initiator)
const event = this.notifyApplicationBeforeVisitingLocation(location, options)
return !event.defaultPrevented
}

Expand All @@ -310,15 +311,16 @@ export class Session {
})
}

notifyApplicationBeforeVisitingLocation(location, target) {
notifyApplicationBeforeVisitingLocation(location, options = {}) {
return dispatch("turbo:before-visit", {
target,
target: options.initiator,
detail: { url: location.href },
cancelable: true
})
}

notifyApplicationAfterVisitingLocation(location, action, direction, target) {
notifyApplicationAfterVisitingLocation(location, options = {}) {
const { action, direction, initiator: target } = options
return dispatch("turbo:visit", { target, detail: { url: location.href, action, direction } })
}

Expand Down

0 comments on commit 1c629b4

Please sign in to comment.