Skip to content

Commit

Permalink
Merge pull request #160 from didkan/fix/potential-server-side-memory-…
Browse files Browse the repository at this point in the history
…leak

Replace deprecated Vue.prototype.$bus with EventBus
  • Loading branch information
dimasch authored May 17, 2021
2 parents 956d535 + 9d7dd59 commit a745bf3
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions hooks/afterRegistration.ts
Original file line number Diff line number Diff line change
@@ -1,25 +1,26 @@
import Vue from 'vue'
import { isServer } from '@vue-storefront/core/helpers'
import * as types from '../store/mutation-types'
import EventBus from '@vue-storefront/core/compatibility/plugins/event-bus'

export function afterRegistration(config, store) {
const VSF_PAYPAL_CODE = 'paypal_express'
let correctPaymentMethod = false

const placeOrder = () => {
if (correctPaymentMethod) {
// Vue.prototype.$bus.$emit('checkout-do-placeOrder', {})
// EventBus.$emit('checkout-do-placeOrder', {})
}
}

if (!isServer) {
Vue.prototype.$bus.$on('set-unique-payment-methods', methods => {
EventBus.$on('set-unique-payment-methods', methods => {
store.commit(`payment-paypal-magento2/${types.SET_BACKEND_PAYMENT_PAYPAL_EXPRESS}`, methods)
})

Vue.prototype.$bus.$on('checkout-before-placeOrder', placeOrder)
EventBus.$on('checkout-before-placeOrder', placeOrder)

Vue.prototype.$bus.$on('checkout-payment-method-changed', (paymentMethodCode) => {
EventBus.$on('checkout-payment-method-changed', (paymentMethodCode) => {
correctPaymentMethod = paymentMethodCode === VSF_PAYPAL_CODE
})
}
Expand Down

0 comments on commit a745bf3

Please sign in to comment.