fix: Use frappe.utils.make_event_emitter

This commit is contained in:
Faris Ansari 2018-11-02 13:30:51 +05:30
parent 71ede099ea
commit 68dbf7f99c
2 changed files with 2 additions and 34 deletions

View File

@ -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;

View File

@ -8,14 +8,13 @@ import { ProfileDialog } from './components/profile_dialog';
// helpers
import './hub_call';
import EventEmitter from './event_emitter';
frappe.provide('hub');
frappe.provide('erpnext.hub');
frappe.provide('frappe.route');
$.extend(erpnext.hub, EventEmitter.prototype);
$.extend(frappe.route, EventEmitter.prototype);
frappe.utils.make_event_emitter(frappe.route);
frappe.utils.make_event_emitter(erpnext.hub);
erpnext.hub.Marketplace = class Marketplace {
constructor({ parent }) {