Here’s a scenario I’ve run into: I’ve got a Galleries
handler that processes an array of uploaded media files and adds them to a Gallery
. I also have a Media
handler that already has actions in place for handling media files (creating thumbnails, etc). I’d like to have the Gallery
handler loop through the array of media files and call the Media
handler for processing. Here’s a rough example:
// Galleries Handler
function handleForm( event, rc, prc ) {
// loop through all of the uploaded media
rc.mediaList.each( function( item ) {
// we already have a handler action that can process media
// run the event just as if we uploaded a single media file
runEvent( 'Media.handleForm' );
} );
}
The problem is, the Galleries
rc
scope will be polluted with data that the Media
handler does not need. I’d like to start fresh so that the Media
handler’s rc
scope only contains the data I want to feed it during each loop.
I know that runEvent()
has the eventArguments
property which gets added as arguments to the method in the target handler like this:
function handleForm( event, rc, prc, [eventArguments...] ) { ... }
If possible, I don’t want Media.handleForm()
to care whether it’s being called from runEvent()
. Is there another way to accomplish what I’m trying to do here? There must be a way to either run an event completely encapsulated with it’s own rc
scope that I can manually feed it (similar to Testbox’s execute()
method).
Thanks for your suggestions and guidance.