mirror of
https://github.com/ansible/awx.git
synced 2026-07-09 15:28:05 -02:30
Cleanup component communication
This commit is contained in:
@@ -1,35 +1,28 @@
|
||||
function addListeners (scope, list) {
|
||||
let listeners = [];
|
||||
function EventService () {
|
||||
this.addListeners = list => {
|
||||
let listeners = [];
|
||||
|
||||
list.forEach(args => {
|
||||
listeners.push(addListener.call(null, scope, ...args));
|
||||
});
|
||||
list.forEach(args => listeners.push(this.addListener(...args)));
|
||||
|
||||
return listeners;
|
||||
}
|
||||
|
||||
function addListener (scope, el, name, fn) {
|
||||
let listener = {
|
||||
fn,
|
||||
name,
|
||||
el
|
||||
return listeners;
|
||||
};
|
||||
|
||||
listener.el.addEventListener(listener.name, listener.fn);
|
||||
this.addListener = (el, name, fn) => {
|
||||
let listener = {
|
||||
fn,
|
||||
name,
|
||||
el
|
||||
};
|
||||
|
||||
return listener;
|
||||
}
|
||||
listener.el.addEventListener(listener.name, listener.fn);
|
||||
|
||||
function remove (listeners) {
|
||||
listeners.forEach(listener => {
|
||||
listener.el.removeEventListener(listener.name, listener.fn);
|
||||
});
|
||||
}
|
||||
return listener;
|
||||
};
|
||||
|
||||
function EventService () {
|
||||
return {
|
||||
addListeners,
|
||||
remove
|
||||
this.remove = listeners => {
|
||||
listeners.forEach(listener => {
|
||||
listener.el.removeEventListener(listener.name, listener.fn);
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -3,5 +3,5 @@ import PathService from './path.service';
|
||||
|
||||
angular
|
||||
.module('at.lib.services', [])
|
||||
.factory('EventService', EventService)
|
||||
.factory('PathService', PathService);
|
||||
.service('EventService', EventService)
|
||||
.service('PathService', PathService);
|
||||
|
||||
@@ -1,16 +1,11 @@
|
||||
function getPartialPath (path) {
|
||||
return `/static/partials/${path}.partial.html`;
|
||||
}
|
||||
|
||||
function getViewPath (path) {
|
||||
return `/static/views/${path}.view.html`;
|
||||
}
|
||||
|
||||
function PathService () {
|
||||
return {
|
||||
getPartialPath,
|
||||
getViewPath
|
||||
this.getPartialPath = path => {
|
||||
return `/static/partials/${path}.partial.html`;
|
||||
};
|
||||
|
||||
this.getViewPath = path => {
|
||||
return `/static/views/${path}.view.html`;
|
||||
}
|
||||
}
|
||||
|
||||
export default PathService;
|
||||
|
||||
Reference in New Issue
Block a user