fix: Use frappe.utils.make_event_emitter
This commit is contained in:
parent
71ede099ea
commit
68dbf7f99c
@ -1,31 +0,0 @@
|
|||||||
/**
|
|
||||||
* Simple EventEmitter which uses jQuery's event system
|
|
||||||
*/
|
|
||||||
class EventEmitter {
|
|
||||||
init() {
|
|
||||||
this.jq = jQuery(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
trigger(evt, data) {
|
|
||||||
!this.jq && this.init();
|
|
||||||
this.jq.trigger(evt, data);
|
|
||||||
}
|
|
||||||
|
|
||||||
once(evt, handler) {
|
|
||||||
!this.jq && this.init();
|
|
||||||
this.jq.one(evt, (e, data) => handler(data));
|
|
||||||
}
|
|
||||||
|
|
||||||
on(evt, handler) {
|
|
||||||
!this.jq && this.init();
|
|
||||||
this.jq.bind(evt, (e, data) => handler(data));
|
|
||||||
}
|
|
||||||
|
|
||||||
off(evt, handler) {
|
|
||||||
!this.jq && this.init();
|
|
||||||
this.jq.unbind(evt, (e, data) => handler(data));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
export default EventEmitter;
|
|
@ -8,14 +8,13 @@ import { ProfileDialog } from './components/profile_dialog';
|
|||||||
|
|
||||||
// helpers
|
// helpers
|
||||||
import './hub_call';
|
import './hub_call';
|
||||||
import EventEmitter from './event_emitter';
|
|
||||||
|
|
||||||
frappe.provide('hub');
|
frappe.provide('hub');
|
||||||
frappe.provide('erpnext.hub');
|
frappe.provide('erpnext.hub');
|
||||||
frappe.provide('frappe.route');
|
frappe.provide('frappe.route');
|
||||||
|
|
||||||
$.extend(erpnext.hub, EventEmitter.prototype);
|
frappe.utils.make_event_emitter(frappe.route);
|
||||||
$.extend(frappe.route, EventEmitter.prototype);
|
frappe.utils.make_event_emitter(erpnext.hub);
|
||||||
|
|
||||||
erpnext.hub.Marketplace = class Marketplace {
|
erpnext.hub.Marketplace = class Marketplace {
|
||||||
constructor({ parent }) {
|
constructor({ parent }) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user