… | |
… | |
695 | You can register multiple handlers for the same event, and this method |
695 | You can register multiple handlers for the same event, and this method |
696 | does not interfere with the C<on_event> mechanism. That is, you can |
696 | does not interfere with the C<on_event> mechanism. That is, you can |
697 | completely ignore this method and handle events in a C<on_event> handler, |
697 | completely ignore this method and handle events in a C<on_event> handler, |
698 | or mix both approaches as you see fit. |
698 | or mix both approaches as you see fit. |
699 | |
699 | |
|
|
700 | Note that unlike commands, event handlers are registered immediately, that |
|
|
701 | is, you can issue a command, then register an event handler and then get |
|
|
702 | an event for this handler I<before> the command is even sent to F<mpv>. If |
|
|
703 | this kind of race is an issue, you can issue a dummy command such as |
|
|
704 | C<get_version> and register the handler when the reply is received. |
|
|
705 | |
700 | =cut |
706 | =cut |
701 | |
707 | |
702 | sub AnyEvent::MPV::Unevent::DESTROY { |
708 | sub AnyEvent::MPV::Unevent::DESTROY { |
703 | my ($evtcb, $event, $evtid) = @{$_[0]}; |
709 | my ($evtcb, $event, $evtid) = @{$_[0]}; |
704 | delete $evtcb->{$event}{$evtid}; |
710 | delete $evtcb->{$event}{$evtid}; |