File "ButtonModuleWatcher.js"

Full Path: /home/siazco/grocery.siazco.se/wp-content/plugins/woocommerce-paypal-payments/modules/ppcp-button/resources/js/modules/ButtonModuleWatcher.js
File size: 803 bytes
MIME-type: text/plain
Charset: utf-8

class ButtonModuleWatcher {
	constructor() {
		this.contextBootstrapRegistry = {};
		this.contextBootstrapWatchers = [];
	}

	watchContextBootstrap( callable ) {
		this.contextBootstrapWatchers.push( callable );
		Object.values( this.contextBootstrapRegistry ).forEach( callable );
	}

	registerContextBootstrap( context, handler ) {
		this.contextBootstrapRegistry[ context ] = {
			context,
			handler,
		};

		// Call registered watchers
		for ( const callable of this.contextBootstrapWatchers ) {
			callable( this.contextBootstrapRegistry[ context ] );
		}
	}
}

window.ppcpResources = window.ppcpResources || {};
const buttonModuleWatcher = ( window.ppcpResources.ButtonModuleWatcher =
	window.ppcpResources.ButtonModuleWatcher || new ButtonModuleWatcher() );

export default buttonModuleWatcher;