Skip to content

Instantly share code, notes, and snippets.

@abcsharp
Created July 14, 2012 09:25
Show Gist options
  • Save abcsharp/3110174 to your computer and use it in GitHub Desktop.
Save abcsharp/3110174 to your computer and use it in GitHub Desktop.
Observableモジュールを使ってみた
open System
open System.Drawing
open System.Windows.Forms
type Form1 =
inherit Form
val private btn1 : Button
val private btn2 : Button
new () as it =
{
btn1 = new Button(Text = "Button1", Location = Point(100, 100))
btn2 = new Button(Text = "Button2", Location = Point(200, 100))
} then it.InitComponents ()
new (text) as it = new Form1() then
it.Text <- text
member private it.InitComponents () =
it.Location <- Point(100, 100)
it.Size <- Size(400, 400)
it.btn1.Click
|> Observable.map (fun _ -> "Button1 Clicked.")
|> Observable.subscribe (MessageBox.Show >> ignore)
|> ignore
it.btn2.Click
|> Observable.map (fun _ -> "Button2 Clicked.")
|> Observable.subscribe (MessageBox.Show >> ignore)
|> ignore
it.Controls.Add(it.btn1)
it.Controls.Add(it.btn2)
Application.EnableVisualStyles()
Application.Run(new Form1("Test"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment