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 { destroyListHandler } from './destroy';
import { listMembershipHandler } from './membership';
export default (): void => {
on('click', 'input[type=checkbox][name=gm-list-check]', listMembershipHandler);
on('click', 'button#create-list', createListHandler);
on('click', 'a#delete-list', destroyListHandler);
on('keyup', 'input#new-list-name', createListInputHandler);
registerEvents([
{ type: 'click', target: 'input[type=checkbox][name=gm-list-check]', handler: listMembershipHandler, global: true },
{ type: 'click', target: 'button#create-list', handler: createListHandler, global: true },
{ 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 { userReportHandler } from './report';
import { on } from 'utilities/on';
import registerEvents from 'retrospring/utilities/registerEvents';
export default (): void => {
on('click', 'button[name=user-action]', userActionHandler);
on('click', 'a[data-action=report-user]', userReportHandler);
registerEvents([
{ type: 'click', target: 'button[name=user-action]', handler: userActionHandler, global: true },
{ type: 'click', target: 'a[data-action=report-user]', handler: userReportHandler, global: true }
]);
}