Access function outside of export


export default {
	name: 'Home',
	data () {
		return {

		}
	},
	methods: {
		resetScreen() {
			// reset the page to the start position

			},

I am trying to use Pusher to listen to events and then call e.g. the . resetScreen method.

async mounted () {

    		var pusher = new Pusher('xxxxxxx', {
      			cluster: 'eu',
      			forceTLS: true
    		});

    		var channel = pusher.subscribe('xxxxxxxxx');
    		channel.bind('xxxxx', function(data) {
				resetScreen();
    		});

		}

results in:
Uncaught TypeError: this.resetScreen is not a function

I presume I need to get the method scoped so it can be accessed?

Found a solution:

Outside of the callback:

var self = this and use self, instead of this

e.g.

var self = this
var channel = pusher.subscribe('xxxxxxxxx');
    		channel.bind('xxxxx', function(data) {
				self.resetScreen();
    		});


Got it from this post, with further details
https://www.reddit.com/r/vuejs/comments/69ueur/trouble_calling_a_method_from_a_callback_in_axios/