import PageSetup from './setup/PageSetup' ; export default function integratePageEventMethods ( pageMethods ) { return pageMethods . reduce ( ( prev , cur ) => { ( prev as any ) [ cur ] = function ( this , ... args ) { const setup = this . $setup ; if ( ! setup ) { return ; } const fns = ( setup . getMethod as any ) ( `events.${ cur }` ) || [ ] ; let result ; for ( const i in fns ) { const fn = fns [ i ] ; result = ( fn as Function ) . call ( this , ... args ) ; } return result ; } ; return prev ; } , { } ) ; }