Use `registerEvents` to register multiple global events

This commit is contained in:
Andreas Nedbal 2022-01-03 05:15:01 +01:00 committed by Andreas Nedbal
parent 707cba8ede
commit 367fe0e7a6
2 changed files with 12 additions and 8 deletions

View File

@ -1,11 +1,13 @@
import { on } from 'retrospring/utilities/on'; import registerEvents from 'retrospring/utilities/registerEvents';
import { createListHandler, createListInputHandler } from './create'; import { createListHandler, createListInputHandler } from './create';
import { destroyListHandler } from './destroy'; import { destroyListHandler } from './destroy';
import { listMembershipHandler } from './membership'; import { listMembershipHandler } from './membership';
export default (): void => { export default (): void => {
on('click', 'input[type=checkbox][name=gm-list-check]', listMembershipHandler); registerEvents([
on('click', 'button#create-list', createListHandler); { type: 'click', target: 'input[type=checkbox][name=gm-list-check]', handler: listMembershipHandler, global: true },
on('click', 'a#delete-list', destroyListHandler); { type: 'click', target: 'button#create-list', handler: createListHandler, global: true },
on('keyup', 'input#new-list-name', createListInputHandler); { type: 'click', target: 'a#delete-list', handler: destroyListHandler, global: true },
{ type: 'click', target: 'input#new-list-name', handler: createListInputHandler, global: true },
]);
} }

View File

@ -1,8 +1,10 @@
import { userActionHandler } from './action'; import { userActionHandler } from './action';
import { userReportHandler } from './report'; import { userReportHandler } from './report';
import { on } from 'utilities/on'; import registerEvents from 'retrospring/utilities/registerEvents';
export default (): void => { export default (): void => {
on('click', 'button[name=user-action]', userActionHandler); registerEvents([
on('click', 'a[data-action=report-user]', userReportHandler); { type: 'click', target: 'button[name=user-action]', handler: userActionHandler, global: true },
{ type: 'click', target: 'a[data-action=report-user]', handler: userReportHandler, global: true }
]);
} }