Compare commits

...

2 Commits

Author SHA1 Message Date
46bfb53db8 add docstring 2023-08-03 14:39:44 +01:00
f669498c69 remove_observers now accepts array of callbacks
callbacks aliases observers

patch bump
2023-08-03 14:15:46 +01:00
3 changed files with 9 additions and 7 deletions

View File

@ -47,10 +47,11 @@ module OBSWS
end
def remove_observer(observer)
observers.delete(observer)
observer = [observer] unless observer.respond_to? :each
observers.reject! { |o| observer.include? o }
end
def notify_observers(event, data)
private def notify_observers(event, data)
observers.each do |o|
if o.is_a? Method
if o.name.to_s == "on_#{snakecase(event)}"
@ -62,6 +63,7 @@ module OBSWS
end
end
alias_method :callbacks, :observers
alias_method :register, :add_observer
alias_method :deregister, :remove_observer
end

View File

@ -26,11 +26,11 @@ module OBSWS
def attrs = @fields.map { |f| snakecase(f.to_s) }
end
class Response < MetaObject
end
class Response < MetaObject; end
# Represents a request response object
class Data < MetaObject
end
class Data < MetaObject; end
# Represents an event data object
module TearDown
def stop_driver

View File

@ -11,7 +11,7 @@ module OBSWS
end
def patch
0
1
end
def to_a