Skip to content

Instantly share code, notes, and snippets.

@panesofglass
Forked from mattpodwysocki/WinForms.rb
Created June 10, 2010 04:57
Show Gist options
  • Save panesofglass/432571 to your computer and use it in GitHub Desktop.
Save panesofglass/432571 to your computer and use it in GitHub Desktop.
Rx in IronRuby
require 'System.CoreEx, Version=1.0.2521.104, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
require 'System.Interactive, Version=1.0.2521.104, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
require 'System.Reactive, Version=1.0.2521.104, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
require 'System.Windows.Forms'
include System
include System::Collections::Generic
include System::Linq
include System::Windows::Forms
class TestForm < Form
def initialize()
self.Text = 'Hello IronRuby'
end
end
form = TestForm.new
clickObservable = Observable.method(:from_event).of(EventArgs).call(form, 'Click')
clickObserver = Observer.method(:create).of(IEvent[EventArgs]).call(
lambda {|on_next| MessageBox::show('clicked') },
lambda { |err| puts err.to_s },
lambda { puts 'completed' })
clickSubcription = clickObservable.subscribe(clickObserver)
Application.run(form)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment