Pass the Renderer as a dependency

This commit is contained in:
Mészáros Róbert 2020-04-09 12:23:44 +03:00
parent 986cec7fef
commit e3041ed5e6
6 changed files with 54 additions and 49 deletions

View file

@ -1,7 +1,6 @@
import Renderer from './Renderer';
class MiniCartBootstap {
constructor(configurator) {
constructor(renderer, configurator) {
this.renderer = renderer;
this.configurator = configurator;
}
@ -10,18 +9,19 @@ class MiniCartBootstap {
return;
}
const renderer = new Renderer(PayPalCommerceGateway.button.mini_cart_wrapper);
jQuery(document.body).
on('wc_fragments_loaded wc_fragments_refreshed', () => {
renderer.render(this.configurator.configuration());
});
renderer.render(this.configurator.configuration());
this.renderer.render(
PayPalCommerceGateway.button.mini_cart_wrapper,
this.configurator.configuration(),
);
}
shouldRender() {
return document.querySelector(PayPalCommerceGateway.button.mini_cart_wrapper)
return document.querySelector(PayPalCommerceGateway.button.mini_cart_wrapper);
}
}