mirror of
https://github.com/primefaces/primevue.git
synced 2025-05-09 17:02:38 +00:00
Change theming implementation - 1/2
This commit is contained in:
parent
6479cad038
commit
43bdf2c3e5
19 changed files with 474 additions and 61 deletions
36
components/lib/themes/utils/service.js
Normal file
36
components/lib/themes/utils/service.js
Normal file
|
@ -0,0 +1,36 @@
|
|||
function createService() {
|
||||
const allHandlers = new Map();
|
||||
|
||||
return {
|
||||
on(type, handler) {
|
||||
let handlers = allHandlers.get(type);
|
||||
|
||||
if (!handlers) handlers = [handler];
|
||||
else handlers.push(handler);
|
||||
|
||||
allHandlers.set(type, handlers);
|
||||
},
|
||||
|
||||
off(type, handler) {
|
||||
let handlers = allHandlers.get(type);
|
||||
|
||||
if (handlers) {
|
||||
handlers.splice(handlers.indexOf(handler) >>> 0, 1);
|
||||
}
|
||||
},
|
||||
|
||||
emit(type, evt) {
|
||||
let handlers = allHandlers.get(type);
|
||||
|
||||
if (handlers) {
|
||||
handlers.slice().map((handler) => {
|
||||
handler(evt);
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
const ThemeService = createService();
|
||||
|
||||
export default ThemeService;
|
Loading…
Add table
Add a link
Reference in a new issue