Skip to content
This repository was archived by the owner on Sep 23, 2022. It is now read-only.

Commit 712b9c3

Browse files
committed
Remove deprecated event methods, part of #32
1 parent 7066082 commit 712b9c3

File tree

1 file changed

+0
-63
lines changed

1 file changed

+0
-63
lines changed

scripts/app.js

-63
Original file line numberDiff line numberDiff line change
@@ -127,69 +127,6 @@ FlareTail.app.Events = class Events {
127127
this.id = id || URL.createObjectURL(new Blob()).substr(-7);
128128
}
129129

130-
/**
131-
* Publish an event asynchronously.
132-
* @deprecated This method fires a DOM event and passes the given data as a reference. For a better performance, use
133-
* trigger() wherever possible.
134-
* @param {String} topic - An event name. Shorthand syntax is supported: #Updated in BugModel means BugModel#Updated,
135-
* #Error in SessionPresenter means SessionPresenter#Error, and so on.
136-
* @param {Object} [data={}] - Data to pass the subscribers. If the instance has set the id property, that id will be
137-
* automatically appended to the data.
138-
* @returns {undefined}
139-
*/
140-
trigger_safe (topic, data = {}) {
141-
if (topic.match(/^#/)) {
142-
topic = this.constructor.name + topic;
143-
}
144-
145-
if (FlareTail.debug) {
146-
console.info('[Event]', topic, this.id, data);
147-
}
148-
149-
FlareTail.helpers.event.trigger(window, topic, { detail: { id: this.id, data }});
150-
}
151-
152-
/**
153-
* Subscribe an event.
154-
* @deprecated This method listens DOM events and receives the given data as a reference. For a better performance,
155-
* use on() wherever possible.
156-
* @param {String} topic - Event name. Shorthand syntax is supported: M#Updated in BugView means BugModel#Updated,
157-
* V#AppMenuItemSelected in ToolbarPresenter means ToolbarView#AppMenuItemSelected, and so on.
158-
* @param {Function} callback - Function called whenever the specified event is fired.
159-
* @param {Boolean} [global=false] - If true, the callback function will be fired even when the event detail object
160-
* and the instance have different id properties. Otherwise, the identity will be respected.
161-
* @returns {undefined}
162-
*/
163-
on_safe (topic, callback, global = false) {
164-
topic = topic.replace(/^([MVP])#/, (match, prefix) => {
165-
return this.constructor.name.match(/(.*)(Model|View|Presenter)$/)[1]
166-
+ { M: 'Model', V: 'View', P: 'Presenter' }[prefix] + '#';
167-
});
168-
169-
window.addEventListener(topic, event => {
170-
if (!global && event.detail && event.detail.id !== this.id) {
171-
return;
172-
}
173-
174-
callback(event.detail.data);
175-
});
176-
}
177-
178-
/**
179-
* Subscribe an event with an automatically determined callback. So this is the 'on' function's shorthand. For
180-
* example, if the topic is 'V#NavigationRequested', on_navigation_requested will be set as the callback function.
181-
* @deprecated This method listens DOM events and receives the given data as a reference. For a better performance,
182-
* use subscribe() wherever possible.
183-
* @param {String} topic - See the 'on' function above for details.
184-
* @param {Boolean} [global=false] - See the 'on' function above for details.
185-
* @returns {undefined}
186-
*/
187-
subscribe_safe (topic, global = false) {
188-
this.on_safe(topic, data => {
189-
this[topic.replace(/^.+?\#/, 'on').replace(/([A-Z])/g, '_$1').toLowerCase()](data);
190-
}, global);
191-
}
192-
193130
/**
194131
* Publish an event asynchronously.
195132
* @param {String} topic - An event name. Shorthand syntax is supported: #Updated in BugModel means BugModel#Updated,

0 commit comments

Comments
 (0)