Skip to content

llambeau/sigslot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SigSlot – Signals and Slots for ruby

SigSlot aims to provide signals and slots in ruby, as in Qt/C++

Signals and slots – Qt’s concept

As wikipedia says:

Signals and slots is a language construct introduced in Qt, which makes it easy to implement the Observer pattern
while avoiding boilerplate code. The concept is that controls (also known as widgets) can send signals containing
event information which can be received by other controls using special functions known as slots.

SigSlot in ruby

Basic example (same example as in Qt’s doc):

require 'sigslot'

class Counter
	include SigSlot
	
	signal :value_changed, [:new_value, :old_value]
	slot :value=
	
	attr_reader :value
	def initialize
		@value = 0
	end
	
	def value=(value)
		if @value != value then
			oldvalue, @value = @value, value
			emit :value_changed, @value, oldvalue
		end
	end
end

About

Signals and Slots for ruby

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages