mirror of
https://github.com/onyx-and-iris/voicemeeter-rb.git
synced 2024-11-21 17:30:49 +00:00
callbacks now public method
register,deregister handle single callbacks or arrays of callbacks
This commit is contained in:
parent
2dab83ec31
commit
1ba1247b7f
@ -3,7 +3,7 @@ require_relative "../../lib/voicemeeter"
|
|||||||
class Main
|
class Main
|
||||||
def initialize(vm)
|
def initialize(vm)
|
||||||
@vm = vm
|
@vm = vm
|
||||||
@vm.register(method(:on_pdirty), method(:on_mdirty), method(:on_midi), method(:on_ldirty))
|
@vm.register([method(:on_pdirty), method(:on_mdirty), method(:on_midi), method(:on_ldirty)])
|
||||||
end
|
end
|
||||||
|
|
||||||
def run
|
def run
|
||||||
|
@ -3,15 +3,17 @@ require_relative "logger"
|
|||||||
module Voicemeeter
|
module Voicemeeter
|
||||||
module Events
|
module Events
|
||||||
module Callback
|
module Callback
|
||||||
private def callbacks
|
def callbacks
|
||||||
@callbacks ||= []
|
@callbacks ||= []
|
||||||
end
|
end
|
||||||
|
|
||||||
def register(*cbs)
|
def register(cbs)
|
||||||
|
cbs = [cbs] unless cbs.respond_to? :each
|
||||||
cbs.each { |cb| callbacks << cb unless callbacks.include? cb }
|
cbs.each { |cb| callbacks << cb unless callbacks.include? cb }
|
||||||
end
|
end
|
||||||
|
|
||||||
def deregister(*cbs)
|
def deregister(cbs)
|
||||||
|
cbs = [cbs] unless cbs.respond_to? :each
|
||||||
callbacks.reject! { |cb| cbs.include? cb }
|
callbacks.reject! { |cb| cbs.include? cb }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user