Wednesday, August 06, 2014

Reactive Extensions for mere mortals (and using them to merge Window Closing KeyEvents and MouseClicks events)

Loek van den Ouweland - Use Reactive Extensions to merge KeyEvents and MouseClicks to close a window

After reading this post, you’ve learned how to convert MouseClick  and KeyDown events into observable collections. You’ll see how you can even make these collections more convenient by merging them into one stream that tells your window to close with or without saving data.

Before we begin

How would you do this with events? Easy. Create a KeyDown event and ButtonClick events.

  • VirtualKey.Enter -> Close(true)
  • VirtualKey.Escape -> Close(false)
  • ButtonOK.Click -> Close(true)
  • ButtonCancel.Click -> Close(false)

...

image..."

I thought this a cool example of how Reactive Extensions is shown to be useful and usable by mere mortals. As they say in RX land, "Life is but a stream [of data]"

No comments:

Post a Comment

NOTE: Anonymous Commenting has been turned off for a while... The comment spammers are just killing me...

ALL comments are moderated. I will review every comment before it will appear on the blog.

Your comment WILL NOT APPEAR UNTIL I approve it. This may take some hours...

I reserve, and will use, the right to not approve ANY comment for ANY reason. I will not usually, but if it's off topic, spam (or even close to spam-like), inflammatory, mean, etc, etc, well... then...

Please see my comment policy for more information if you are interested.

Thanks,
Greg

PS. I am proactively moderating comments. Your comment WILL NOT APPEAR UNTIL I approve it. This may take some hours...