Skip to content

Instantly share code, notes, and snippets.

@julien51
Last active March 21, 2020 13:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save julien51/8d771a84ad5db0be9ad00928cd54e8c1 to your computer and use it in GitHub Desktop.
Save julien51/8d771a84ad5db0be9ad00928cd54e8c1 to your computer and use it in GitHub Desktop.
<template>
<div>
<div v-if="unlockState === 'locked'">locked</div>
<div v-if="unlockState === 'pending'">pending</div>
<div v-if="unlockState === 'unlocked'">unlocked</div>
<button @click="checkout()">checkout</button>
</div>
</template>
<script>
export default {
data: function() {
return {
unlockHandler: null,
unlockState: 'pending'
}
},
mounted() {
this.$nextTick(function() {
window.addEventListener('unlockProtocol', this.unlockHandler)
})
},
created() {
this.unlockHandler = () -> {
var state = e.detail
this.unlockState = state
}
},
beforeDestroy() {
window.removeEventListener('unlockProtocol', this.unlockHandler)
},
methods: {
checkout() {
window.unlockProtocol && window.unlockProtocol.loadCheckoutModal()
}
}
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment