[{"data":1,"prerenderedAt":464},["ShallowReactive",2],{"i-feather:search":3,"i-feather:x":8,"i-feather:moon":10,"i-feather:sun":12,"i-lucide:house-heart":14,"i-fa-brands:youtube":16,"i-fa-brands:twitch":20,"i-fa-brands:github":22,"i-fa-brands:linkedin":25,"i-fa-brands:stack-overflow":28,"i-simple-icons:bluesky":31,"i-fa-brands:mastodon":33,"i-fa-regular:envelope":35,"i-fa-solid:rss":37,"post-\u002Freactive-extensions-part1-replacing-events\u002F":39,"i-fa-solid:share-alt":448,"i-fa-brands:facebook":450,"i-fa-brands:twitter":452,"i-fa-brands:reddit":454,"i-fa-brands:patreon":456,"i-simple-icons:buymeacoffee":458,"i-fa-brands:paypal":460,"i-fa-regular:question-circle":462},{"left":4,"top":4,"width":5,"height":5,"rotate":4,"vFlip":6,"hFlip":6,"body":7},0,24,false,"\u003Cg fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\">\u003Ccircle cx=\"11\" cy=\"11\" r=\"8\"\u002F>\u003Cpath d=\"m21 21l-4.35-4.35\"\u002F>\u003C\u002Fg>",{"left":4,"top":4,"width":5,"height":5,"rotate":4,"vFlip":6,"hFlip":6,"body":9},"\u003Cpath fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M18 6L6 18M6 6l12 12\"\u002F>",{"left":4,"top":4,"width":5,"height":5,"rotate":4,"vFlip":6,"hFlip":6,"body":11},"\u003Cpath fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M21 12.79A9 9 0 1 1 11.21 3A7 7 0 0 0 21 12.79\"\u002F>",{"left":4,"top":4,"width":5,"height":5,"rotate":4,"vFlip":6,"hFlip":6,"body":13},"\u003Cg fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\">\u003Ccircle cx=\"12\" cy=\"12\" r=\"5\"\u002F>\u003Cpath d=\"M12 1v2m0 18v2M4.22 4.22l1.42 1.42m12.72 12.72l1.42 1.42M1 12h2m18 0h2M4.22 19.78l1.42-1.42M18.36 5.64l1.42-1.42\"\u002F>\u003C\u002Fg>",{"left":4,"top":4,"width":5,"height":5,"rotate":4,"vFlip":6,"hFlip":6,"body":15},"\u003Cg fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\">\u003Cpath d=\"M8.62 13.8A2.25 2.25 0 1 1 12 10.836a2.25 2.25 0 1 1 3.38 2.966l-2.626 2.856a.998.998 0 0 1-1.507 0z\"\u002F>\u003Cpath d=\"M3 10a2 2 0 0 1 .709-1.528l7-6a2 2 0 0 1 2.582 0l7 6A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z\"\u002F>\u003C\u002Fg>",{"left":4,"top":4,"width":17,"height":18,"rotate":4,"vFlip":6,"hFlip":6,"body":19},576,512,"\u003Cpath fill=\"currentColor\" d=\"M549.655 124.083c-6.281-23.65-24.787-42.276-48.284-48.597C458.781 64 288 64 288 64S117.22 64 74.629 75.486c-23.497 6.322-42.003 24.947-48.284 48.597c-11.412 42.867-11.412 132.305-11.412 132.305s0 89.438 11.412 132.305c6.281 23.65 24.787 41.5 48.284 47.821C117.22 448 288 448 288 448s170.78 0 213.371-11.486c23.497-6.321 42.003-24.171 48.284-47.821c11.412-42.867 11.412-132.305 11.412-132.305s0-89.438-11.412-132.305m-317.51 213.508V175.185l142.739 81.205z\"\u002F>",{"left":4,"top":4,"width":18,"height":18,"rotate":4,"vFlip":6,"hFlip":6,"body":21},"\u003Cpath fill=\"currentColor\" d=\"M391.17 103.47h-38.63v109.7h38.63ZM285 103h-38.63v109.75H285ZM120.83 0L24.31 91.42v329.16h115.83V512l96.53-91.42h77.25L487.69 256V0Zm328.24 237.75l-77.22 73.12h-77.24l-67.6 64v-64h-86.87V36.58h308.93Z\"\u002F>",{"left":4,"top":4,"width":23,"height":18,"rotate":4,"vFlip":6,"hFlip":6,"body":24},496,"\u003Cpath fill=\"currentColor\" d=\"M165.9 397.4c0 2-2.3 3.6-5.2 3.6c-3.3.3-5.6-1.3-5.6-3.6c0-2 2.3-3.6 5.2-3.6c3-.3 5.6 1.3 5.6 3.6m-31.1-4.5c-.7 2 1.3 4.3 4.3 4.9c2.6 1 5.6 0 6.2-2s-1.3-4.3-4.3-5.2c-2.6-.7-5.5.3-6.2 2.3m44.2-1.7c-2.9.7-4.9 2.6-4.6 4.9c.3 2 2.9 3.3 5.9 2.6c2.9-.7 4.9-2.6 4.6-4.6c-.3-1.9-3-3.2-5.9-2.9M244.8 8C106.1 8 0 113.3 0 252c0 110.9 69.8 205.8 169.5 239.2c12.8 2.3 17.3-5.6 17.3-12.1c0-6.2-.3-40.4-.3-61.4c0 0-70 15-84.7-29.8c0 0-11.4-29.1-27.8-36.6c0 0-22.9-15.7 1.6-15.4c0 0 24.9 2 38.6 25.8c21.9 38.6 58.6 27.5 72.9 20.9c2.3-16 8.8-27.1 16-33.7c-55.9-6.2-112.3-14.3-112.3-110.5c0-27.5 7.6-41.3 23.6-58.9c-2.6-6.5-11.1-33.3 2.6-67.9c20.9-6.5 69 27 69 27c20-5.6 41.5-8.5 62.8-8.5s42.8 2.9 62.8 8.5c0 0 48.1-33.6 69-27c13.7 34.7 5.2 61.4 2.6 67.9c16 17.7 25.8 31.5 25.8 58.9c0 96.5-58.9 104.2-114.8 110.5c9.2 7.9 17 22.9 17 46.4c0 33.7-.3 75.4-.3 83.6c0 6.5 4.6 14.4 17.3 12.1C428.2 457.8 496 362.9 496 252C496 113.3 383.5 8 244.8 8M97.2 352.9c-1.3 1-1 3.3.7 5.2c1.6 1.6 3.9 2.3 5.2 1c1.3-1 1-3.3-.7-5.2c-1.6-1.6-3.9-2.3-5.2-1m-10.8-8.1c-.7 1.3.3 2.9 2.3 3.9c1.6 1 3.6.7 4.3-.7c.7-1.3-.3-2.9-2.3-3.9c-2-.6-3.6-.3-4.3.7m32.4 35.6c-1.6 1.3-1 4.3 1.3 6.2c2.3 2.3 5.2 2.6 6.5 1c1.3-1.3.7-4.3-1.3-6.2c-2.2-2.3-5.2-2.6-6.5-1m-11.4-14.7c-1.6 1-1.6 3.6 0 5.9s4.3 3.3 5.6 2.3c1.6-1.3 1.6-3.9 0-6.2c-1.4-2.3-4-3.3-5.6-2\"\u002F>",{"left":4,"top":4,"width":26,"height":18,"rotate":4,"vFlip":6,"hFlip":6,"body":27},448,"\u003Cpath fill=\"currentColor\" d=\"M416 32H31.9C14.3 32 0 46.5 0 64.3v383.4C0 465.5 14.3 480 31.9 480H416c17.6 0 32-14.5 32-32.3V64.3c0-17.8-14.4-32.3-32-32.3M135.4 416H69V202.2h66.5V416zm-33.2-243c-21.3 0-38.5-17.3-38.5-38.5S80.9 96 102.2 96c21.2 0 38.5 17.3 38.5 38.5c0 21.3-17.2 38.5-38.5 38.5m282.1 243h-66.4V312c0-24.8-.5-56.7-34.5-56.7c-34.6 0-39.9 27-39.9 54.9V416h-66.4V202.2h63.7v29.2h.9c8.9-16.8 30.6-34.5 62.9-34.5c67.2 0 79.7 44.3 79.7 101.9z\"\u002F>",{"left":4,"top":4,"width":29,"height":18,"rotate":4,"vFlip":6,"hFlip":6,"body":30},384,"\u003Cpath fill=\"currentColor\" d=\"M290.7 311L95 269.7L86.8 309l195.7 41zm51-87L188.2 95.7l-25.5 30.8l153.5 128.3zm-31.2 39.7L129.2 179l-16.7 36.5L293.7 300zM262 32l-32 24l119.3 160.3l32-24zm20.5 328h-200v39.7h200zm39.7 80H42.7V320h-40v160h359.5V320h-40z\"\u002F>",{"left":4,"top":4,"width":5,"height":5,"rotate":4,"vFlip":6,"hFlip":6,"body":32},"\u003Cpath fill=\"currentColor\" d=\"M5.202 2.857C7.954 4.922 10.913 9.11 12 11.358c1.087-2.247 4.046-6.436 6.798-8.501C20.783 1.366 24 .213 24 3.883c0 .732-.42 6.156-.667 7.037c-.856 3.061-3.978 3.842-6.755 3.37c4.854.826 6.089 3.562 3.422 6.299c-5.065 5.196-7.28-1.304-7.847-2.97c-.104-.305-.152-.448-.153-.327c0-.121-.05.022-.153.327c-.568 1.666-2.782 8.166-7.847 2.97c-2.667-2.737-1.432-5.473 3.422-6.3c-2.777.473-5.899-.308-6.755-3.369C.42 10.04 0 4.615 0 3.883c0-3.67 3.217-2.517 5.202-1.026\"\u002F>",{"left":4,"top":4,"width":26,"height":18,"rotate":4,"vFlip":6,"hFlip":6,"body":34},"\u003Cpath fill=\"currentColor\" d=\"M433 179.11c0-97.2-63.71-125.7-63.71-125.7c-62.52-28.7-228.56-28.4-290.48 0c0 0-63.72 28.5-63.72 125.7c0 115.7-6.6 259.4 105.63 289.1c40.51 10.7 75.32 13 103.33 11.4c50.81-2.8 79.32-18.1 79.32-18.1l-1.7-36.9s-36.31 11.4-77.12 10.1c-40.41-1.4-83-4.4-89.63-54a102.5 102.5 0 0 1-.9-13.9c85.63 20.9 158.65 9.1 178.75 6.7c56.12-6.7 105-41.3 111.23-72.9c9.8-49.8 9-121.5 9-121.5m-75.12 125.2h-46.63v-114.2c0-49.7-64-51.6-64 6.9v62.5h-46.33V197c0-58.5-64-56.6-64-6.9v114.2H90.19c0-122.1-5.2-147.9 18.41-175c25.9-28.9 79.82-30.8 103.83 6.1l11.6 19.5l11.6-19.5c24.11-37.1 78.12-34.8 103.83-6.1c23.71 27.3 18.4 53 18.4 175z\"\u002F>",{"left":4,"top":4,"width":18,"height":18,"rotate":4,"vFlip":6,"hFlip":6,"body":36},"\u003Cpath fill=\"currentColor\" d=\"M464 64H48C21.49 64 0 85.49 0 112v288c0 26.51 21.49 48 48 48h416c26.51 0 48-21.49 48-48V112c0-26.51-21.49-48-48-48m0 48v40.805c-22.422 18.259-58.168 46.651-134.587 106.49c-16.841 13.247-50.201 45.072-73.413 44.701c-23.208.375-56.579-31.459-73.413-44.701C106.18 199.465 70.425 171.067 48 152.805V112zM48 400V214.398c22.914 18.251 55.409 43.862 104.938 82.646c21.857 17.205 60.134 55.186 103.062 54.955c42.717.231 80.509-37.199 103.053-54.947c49.528-38.783 82.032-64.401 104.947-82.653V400z\"\u002F>",{"left":4,"top":4,"width":26,"height":18,"rotate":4,"vFlip":6,"hFlip":6,"body":38},"\u003Cpath fill=\"currentColor\" d=\"M128.081 415.959c0 35.369-28.672 64.041-64.041 64.041S0 451.328 0 415.959s28.672-64.041 64.041-64.041s64.04 28.673 64.04 64.041m175.66 47.25c-8.354-154.6-132.185-278.587-286.95-286.95C7.656 175.765 0 183.105 0 192.253v48.069c0 8.415 6.49 15.472 14.887 16.018c111.832 7.284 201.473 96.702 208.772 208.772c.547 8.397 7.604 14.887 16.018 14.887h48.069c9.149.001 16.489-7.655 15.995-16.79m144.249.288C439.596 229.677 251.465 40.445 16.503 32.01C7.473 31.686 0 38.981 0 48.016v48.068c0 8.625 6.835 15.645 15.453 15.999c191.179 7.839 344.627 161.316 352.465 352.465c.353 8.618 7.373 15.453 15.999 15.453h48.068c9.034-.001 16.329-7.474 16.005-16.504\"\u002F>",{"id":40,"title":41,"author":42,"body":43,"comments":297,"date":428,"dateModified":429,"description":430,"extension":431,"headings":432,"heroImage":437,"meta":438,"path":55,"permalink":55,"published":439,"stem":440,"tags":441,"timeToRead":447},"posts\u002Fposts\u002F2014\u002Freactive-extensions-part1-replacing-events\u002Findex.md","Reactive Extensions (Rx) - Part 1 - Replacing C# Events","Muhammad Rehan Saeed",{"type":44,"value":45,"toc":294},"minimark",[46,99,113,116,139,142,149,152,155,182,185,188,191,198,201,204,207,210,221,224,227,238,241,244,258,261,273,284,290],[47,48,49,57,63,69,75,81,87,93],"ol",{},[50,51,52],"li",{},[53,54,56],"a",{"href":55},"\u002Freactive-extensions-part1-replacing-events\u002F","Reactive Extensions (Rx) - Replacing C# Events",[50,58,59],{},[53,60,62],{"href":61},"\u002Freactive-extensions-part2-wrapping-events\u002F","Reactive Extensions (Rx) - Wrapping C# Events",[50,64,65],{},[53,66,68],{"href":67},"\u002Freactive-extensions-part3-naming-conventions\u002F","Reactive Extensions (Rx) - Naming Conventions",[50,70,71],{},[53,72,74],{"href":73},"\u002Freactive-extensions-part4-replacing-timers\u002F","Reactive Extensions (Rx) - Replacing Timers",[50,76,77],{},[53,78,80],{"href":79},"\u002Freactive-extensions-part5-awaiting-observables\u002F","Reactive Extensions (Rx) - Awaiting Observables",[50,82,83],{},[53,84,86],{"href":85},"\u002Freactive-extensions-part6-task-toobservable\u002F","Reactive Extensions (Rx) - Task ToObservable",[50,88,89],{},[53,90,92],{"href":91},"\u002Freactive-extensions-part7-sample-events\u002F","Reactive Extensions (Rx) - Sample Events",[50,94,95],{},[53,96,98],{"href":97},"\u002Freactive-extensions-rx-part-8-timeouts\u002F","Reactive Extensions (Rx) - Timeouts",[100,101,102,103,112],"p",{},"For those who have not tried Reactive Extensions (Rx) yet, I highly recommend it. If I had to describe it in a few words it would be 'Linq to events'. If you have not already learned about it, ",[53,104,111],{"href":105,"rel":106,"target":110},"http:\u002F\u002Fwww.introtorx.com\u002Fuat\u002Fcontent\u002Fv1.0.10621.0\u002F00_Foreword.html",[107,108,109],"nofollow","noopener","noreferrer","_blank","this"," is by far the best resource on learning its intricacies.",[100,114,115],{},"I have spent a lot of time reading about Reactive Extensions but what I have not found in my research is examples or pointers on how or even where it should be used in preference to other code. One area where you should definitely consider using Reactive Extensions is as a direct replacement for bog standard C# events, which have been around since C# 1.0. This post will explain how.",[117,118,120,138],"h1",{"id":119},"exposing-an-event",[53,121,124],{"href":122,"aria-hidden":123},"#exposing-an-event","true",[125,126,132],"svg",{"xmlns":127,"xmlns:xlink":128,"viewBox":129,"version":130,"width":131,"height":131,"aria-hidden":123},"http:\u002F\u002Fwww.w3.org\u002F2000\u002Fsvg","http:\u002F\u002Fwww.w3.org\u002F1999\u002Fxlink","0 0 16 16","1.1",22,[133,134],"path",{"fill":135,"fill-rule":136,"d":137},"currentColor","evenodd","M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z","Exposing an Event",[100,140,141],{},"Here is an example of a standard C# event using the standard recommended pattern:",[143,144],"pre",{"className":145,"language":146,"meta":147,"style":147,"html":148},"language-cs shiki shiki-themes light-plus monokai","cs","","\u003Cspan class=\"line\">\u003Cspan class=\"sJvqV\">public\u003C\u002Fspan>\u003Cspan class=\"s4J9F\"> class\u003C\u002Fspan>\u003Cspan class=\"sw29p\"> JetFighter\n\u003C\u002Fspan>\u003C\u002Fspan>\u003Cspan class=\"line\">\u003Cspan class=\"sjLUg\">{\n\u003C\u002Fspan>\u003C\u002Fspan>\u003Cspan class=\"line\">\u003Cspan class=\"sJvqV\">    public\u003C\u002Fspan>\u003Cspan class=\"s4J9F\"> event\u003C\u002Fspan>\u003Cspan class=\"sw29p\"> EventHandler\u003C\u002Fspan>\u003Cspan class=\"sjLUg\">&lt;\u003C\u002Fspan>\u003Cspan class=\"sw29p\">JetFighterEventArgs\u003C\u002Fspan>\u003Cspan class=\"sjLUg\">&gt; \u003C\u002Fspan>\u003Cspan class=\"sFrd5\">PlaneSpotted\u003C\u002Fspan>\u003Cspan class=\"sjLUg\">;\n\u003C\u002Fspan>\u003C\u002Fspan>\u003Cspan class=\"line\">\u003Cspan>\n\u003C\u002Fspan>\u003C\u002Fspan>\u003Cspan class=\"line\">\u003Cspan class=\"sJvqV\">    public\u003C\u002Fspan>\u003Cspan class=\"sJvqV\"> void\u003C\u002Fspan>\u003Cspan class=\"sWm5y\"> SpotPlane\u003C\u002Fspan>\u003Cspan class=\"sjLUg\">(\u003C\u002Fspan>\u003Cspan class=\"sw29p\">JetFighter\u003C\u002Fspan>\u003Cspan class=\"sFrd5\"> jetFighter\u003C\u002Fspan>\u003Cspan class=\"sjLUg\">)\n\u003C\u002Fspan>\u003C\u002Fspan>\u003Cspan class=\"line\">\u003Cspan class=\"sjLUg\">    {\n\u003C\u002Fspan>\u003C\u002Fspan>\u003Cspan class=\"line\">\u003Cspan class=\"sw29p\">        EventHandler\u003C\u002Fspan>\u003Cspan class=\"sjLUg\">&lt;\u003C\u002Fspan>\u003Cspan class=\"sw29p\">JetFighterEventArgs\u003C\u002Fspan>\u003Cspan class=\"sjLUg\">&gt; \u003C\u002Fspan>\u003Cspan class=\"sFrd5\">eventHandler\u003C\u002Fspan>\u003Cspan class=\"snCLD\"> =\u003C\u002Fspan>\u003Cspan class=\"sK46n\"> this\u003C\u002Fspan>\u003Cspan class=\"sjLUg\">.\u003C\u002Fspan>\u003Cspan class=\"sFrd5\">PlaneSpotted\u003C\u002Fspan>\u003Cspan class=\"sjLUg\">;\n\u003C\u002Fspan>\u003C\u002Fspan>\u003Cspan class=\"line\">\u003Cspan class=\"smL5M\">        if\u003C\u002Fspan>\u003Cspan class=\"sjLUg\"> (\u003C\u002Fspan>\u003Cspan class=\"sFrd5\">eventHandler\u003C\u002Fspan>\u003Cspan class=\"snCLD\"> !=\u003C\u002Fspan>\u003Cspan class=\"sMc8R\"> null\u003C\u002Fspan>\u003Cspan class=\"sjLUg\">)\n\u003C\u002Fspan>\u003C\u002Fspan>\u003Cspan class=\"line\">\u003Cspan class=\"sjLUg\">        {\n\u003C\u002Fspan>\u003C\u002Fspan>\u003Cspan class=\"line\">\u003Cspan class=\"sWm5y\">            eventHandler\u003C\u002Fspan>\u003Cspan class=\"sjLUg\">(\u003C\u002Fspan>\u003Cspan class=\"sK46n\">this\u003C\u002Fspan>\u003Cspan class=\"sjLUg\">, \u003C\u002Fspan>\u003Cspan class=\"sJvqV\">new\u003C\u002Fspan>\u003Cspan class=\"sw29p\"> JetFighterEventArgs\u003C\u002Fspan>\u003Cspan class=\"sjLUg\">(\u003C\u002Fspan>\u003Cspan class=\"sFrd5\">jetfighter\u003C\u002Fspan>\u003Cspan class=\"sjLUg\">));\n\u003C\u002Fspan>\u003C\u002Fspan>\u003Cspan class=\"line\">\u003Cspan class=\"sjLUg\">        }\n\u003C\u002Fspan>\u003C\u002Fspan>\u003Cspan class=\"line\">\u003Cspan class=\"sjLUg\">    }\n\u003C\u002Fspan>\u003C\u002Fspan>\u003Cspan class=\"line\">\u003Cspan class=\"sjLUg\">}\n\u003C\u002Fspan>\u003C\u002Fspan>",[100,150,151],{},"Now this is how you replace it using Reactive Extensions:",[143,153],{"className":145,"language":146,"meta":147,"style":147,"html":154},"\u003Cspan class=\"line\">\u003Cspan class=\"sJvqV\">public\u003C\u002Fspan>\u003Cspan class=\"s4J9F\"> class\u003C\u002Fspan>\u003Cspan class=\"sw29p\"> JetFighter\n\u003C\u002Fspan>\u003C\u002Fspan>\u003Cspan class=\"line\">\u003Cspan class=\"sjLUg\">{\n\u003C\u002Fspan>\u003C\u002Fspan>\u003Cspan class=\"line\">\u003Cspan class=\"sJvqV\">    private\u003C\u002Fspan>\u003Cspan class=\"sw29p\"> Subject\u003C\u002Fspan>\u003Cspan class=\"sjLUg\">&lt;\u003C\u002Fspan>\u003Cspan class=\"sw29p\">JetFighter\u003C\u002Fspan>\u003Cspan class=\"sjLUg\">&gt; \u003C\u002Fspan>\u003Cspan class=\"sFrd5\">planeSpotted\u003C\u002Fspan>\u003Cspan class=\"snCLD\"> =\u003C\u002Fspan>\u003Cspan class=\"sJvqV\"> new\u003C\u002Fspan>\u003Cspan class=\"sw29p\"> Subject\u003C\u002Fspan>\u003Cspan class=\"sjLUg\">&lt;\u003C\u002Fspan>\u003Cspan class=\"sw29p\">JetFighter\u003C\u002Fspan>\u003Cspan class=\"sjLUg\">&gt;();\n\u003C\u002Fspan>\u003C\u002Fspan>\u003Cspan class=\"line\">\u003Cspan>\n\u003C\u002Fspan>\u003C\u002Fspan>\u003Cspan class=\"line\">\u003Cspan class=\"sJvqV\">    public\u003C\u002Fspan>\u003Cspan class=\"sw29p\"> IObservable\u003C\u002Fspan>\u003Cspan class=\"sjLUg\">&lt;\u003C\u002Fspan>\u003Cspan class=\"sw29p\">JetFighter\u003C\u002Fspan>\u003Cspan class=\"sjLUg\">&gt; \u003C\u002Fspan>\u003Cspan class=\"sFrd5\">PlaneSpotted\u003C\u002Fspan>\u003Cspan class=\"snCLD\"> =&gt;\u003C\u002Fspan>\u003Cspan class=\"sK46n\"> this\u003C\u002Fspan>\u003Cspan class=\"sjLUg\">.\u003C\u002Fspan>\u003Cspan class=\"sFrd5\">planeSpotted\u003C\u002Fspan>\u003Cspan class=\"sjLUg\">.\u003C\u002Fspan>\u003Cspan class=\"sWm5y\">AsObservable\u003C\u002Fspan>\u003Cspan class=\"sjLUg\">();\n\u003C\u002Fspan>\u003C\u002Fspan>\u003Cspan class=\"line\">\u003Cspan>\n\u003C\u002Fspan>\u003C\u002Fspan>\u003Cspan class=\"line\">\u003Cspan class=\"sJvqV\">    public\u003C\u002Fspan>\u003Cspan class=\"sJvqV\"> void\u003C\u002Fspan>\u003Cspan class=\"sWm5y\"> SpotPlane\u003C\u002Fspan>\u003Cspan class=\"sjLUg\">(\u003C\u002Fspan>\u003Cspan class=\"sw29p\">JetFighter\u003C\u002Fspan>\u003Cspan class=\"sFrd5\"> jetFighter\u003C\u002Fspan>\u003Cspan class=\"sjLUg\">) \u003C\u002Fspan>\u003Cspan class=\"snCLD\">=&gt;\u003C\u002Fspan>\u003Cspan class=\"sK46n\"> this\u003C\u002Fspan>\u003Cspan class=\"sjLUg\">.\u003C\u002Fspan>\u003Cspan class=\"sFrd5\">planeSpotted\u003C\u002Fspan>\u003Cspan class=\"sjLUg\">.\u003C\u002Fspan>\u003Cspan class=\"sWm5y\">OnNext\u003C\u002Fspan>\u003Cspan class=\"sjLUg\">(\u003C\u002Fspan>\u003Cspan class=\"sFrd5\">jetFighter\u003C\u002Fspan>\u003Cspan class=\"sjLUg\">);\n\u003C\u002Fspan>\u003C\u002Fspan>\u003Cspan class=\"line\">\u003Cspan class=\"sjLUg\">}\n\u003C\u002Fspan>\u003C\u002Fspan>",[100,156,157,158,162,163,166,167,170,171,174,175,177,178,181],{},"So far it's all pretty straightforward, we have replaced the event with a property returning ",[159,160,161],"code",{},"IObservable\u003CT>",". Raising the event is a simple matter of calling the ",[159,164,165],{},"OnNext"," method on the Subject class. Finally, we do not return our ",[159,168,169],{},"Subject\u003CT>"," directly in our ",[159,172,173],{},"PlaneSpotted"," property, as someone could cast it back to ",[159,176,169],{}," and raise their own events! Instead we use the ",[159,179,180],{},"AsObservable"," method which returns a middle man. So far so good.",[100,183,184],{},"Reactive Extensions also has the added concept of errors and completion, which C# events do not have. These are optional added concepts and not required for replacing C# events directly but worth knowing about, as they add an extra dimension to events which may be useful to you.",[100,186,187],{},"The first concept is dealing with errors. What happens if there is an exception while you are spotting the plane and you want to notify your subscribers that there is a problem? Well you can do that, like this:",[143,189],{"className":145,"language":146,"meta":147,"style":147,"html":190},"\u003Cspan class=\"line\">\u003Cspan class=\"sJvqV\">public\u003C\u002Fspan>\u003Cspan class=\"sJvqV\"> void\u003C\u002Fspan>\u003Cspan class=\"sWm5y\"> SpotPlane\u003C\u002Fspan>\u003Cspan class=\"sjLUg\">(\u003C\u002Fspan>\u003Cspan class=\"sw29p\">JetFighter\u003C\u002Fspan>\u003Cspan class=\"sFrd5\"> jetFighter\u003C\u002Fspan>\u003Cspan class=\"sjLUg\">)\n\u003C\u002Fspan>\u003C\u002Fspan>\u003Cspan class=\"line\">\u003Cspan class=\"sjLUg\">{\n\u003C\u002Fspan>\u003C\u002Fspan>\u003Cspan class=\"line\">\u003Cspan class=\"smL5M\">    try\n\u003C\u002Fspan>\u003C\u002Fspan>\u003Cspan class=\"line\">\u003Cspan class=\"sjLUg\">    {\n\u003C\u002Fspan>\u003C\u002Fspan>\u003Cspan class=\"line\">\u003Cspan class=\"smL5M\">        if\u003C\u002Fspan>\u003Cspan class=\"sjLUg\"> (\u003C\u002Fspan>\u003Cspan class=\"sJvqV\">string\u003C\u002Fspan>\u003Cspan class=\"sjLUg\">.\u003C\u002Fspan>\u003Cspan class=\"sWm5y\">Equals\u003C\u002Fspan>\u003Cspan class=\"sjLUg\">(\u003C\u002Fspan>\u003Cspan class=\"sFrd5\">jetFighter\u003C\u002Fspan>\u003Cspan class=\"sjLUg\">.\u003C\u002Fspan>\u003Cspan class=\"sFrd5\">Name\u003C\u002Fspan>\u003Cspan class=\"sjLUg\">, \u003C\u002Fspan>\u003Cspan class=\"swiDo\">\"UFO\"\u003C\u002Fspan>\u003Cspan class=\"sjLUg\">))\n\u003C\u002Fspan>\u003C\u002Fspan>\u003Cspan class=\"line\">\u003Cspan class=\"sjLUg\">        {\n\u003C\u002Fspan>\u003C\u002Fspan>\u003Cspan class=\"line\">\u003Cspan class=\"smL5M\">            throw\u003C\u002Fspan>\u003Cspan class=\"sJvqV\"> new\u003C\u002Fspan>\u003Cspan class=\"sw29p\"> Exception\u003C\u002Fspan>\u003Cspan class=\"sjLUg\">(\u003C\u002Fspan>\u003Cspan class=\"swiDo\">\"UFO Found\"\u003C\u002Fspan>\u003Cspan class=\"sjLUg\">)\n\u003C\u002Fspan>\u003C\u002Fspan>\u003Cspan class=\"line\">\u003Cspan class=\"sjLUg\">        }\n\u003C\u002Fspan>\u003C\u002Fspan>\u003Cspan class=\"line\">\u003Cspan>\n\u003C\u002Fspan>\u003C\u002Fspan>\u003Cspan class=\"line\">\u003Cspan class=\"sK46n\">        this\u003C\u002Fspan>\u003Cspan class=\"sjLUg\">.\u003C\u002Fspan>\u003Cspan class=\"sFrd5\">planeSpotted\u003C\u002Fspan>\u003Cspan class=\"sjLUg\">.\u003C\u002Fspan>\u003Cspan class=\"sWm5y\">OnNext\u003C\u002Fspan>\u003Cspan class=\"sjLUg\">(\u003C\u002Fspan>\u003Cspan class=\"sFrd5\">jetFighter\u003C\u002Fspan>\u003Cspan class=\"sjLUg\">);\n\u003C\u002Fspan>\u003C\u002Fspan>\u003Cspan class=\"line\">\u003Cspan class=\"sjLUg\">    }\n\u003C\u002Fspan>\u003C\u002Fspan>\u003Cspan class=\"line\">\u003Cspan class=\"smL5M\">    catch\u003C\u002Fspan>\u003Cspan class=\"sjLUg\"> (\u003C\u002Fspan>\u003Cspan class=\"sw29p\">Exception\u003C\u002Fspan>\u003Cspan class=\"sFrd5\"> exception\u003C\u002Fspan>\u003Cspan class=\"sjLUg\">)\n\u003C\u002Fspan>\u003C\u002Fspan>\u003Cspan class=\"line\">\u003Cspan class=\"sjLUg\">    {\n\u003C\u002Fspan>\u003C\u002Fspan>\u003Cspan class=\"line\">\u003Cspan class=\"sK46n\">        this\u003C\u002Fspan>\u003Cspan class=\"sjLUg\">.\u003C\u002Fspan>\u003Cspan class=\"sFrd5\">planeSpotted\u003C\u002Fspan>\u003Cspan class=\"sjLUg\">.\u003C\u002Fspan>\u003Cspan class=\"sWm5y\">OnError\u003C\u002Fspan>\u003Cspan class=\"sjLUg\">(\u003C\u002Fspan>\u003Cspan class=\"sFrd5\">exception\u003C\u002Fspan>\u003Cspan class=\"sjLUg\">);\n\u003C\u002Fspan>\u003C\u002Fspan>\u003Cspan class=\"line\">\u003Cspan class=\"sjLUg\">    }\n\u003C\u002Fspan>\u003C\u002Fspan>\u003Cspan class=\"line\">\u003Cspan class=\"sjLUg\">}\n\u003C\u002Fspan>\u003C\u002Fspan>",[100,192,193,194,197],{},"Here we are using the ",[159,195,196],{},"OnError"," method to notify all the events subscribers that there has been an exception.",[100,199,200],{},"So what about the concept of completion? Well, that's just as simple. Suppose that you have spotted all the planes and you want to notify all your subscribers that there will be no more spotted planes. You can do that like this:",[143,202],{"className":145,"language":146,"meta":147,"style":147,"html":203},"\u003Cspan class=\"line\">\u003Cspan class=\"sJvqV\">public\u003C\u002Fspan>\u003Cspan class=\"sJvqV\"> void\u003C\u002Fspan>\u003Cspan class=\"sWm5y\"> AllPlanesSpotted\u003C\u002Fspan>\u003Cspan class=\"sjLUg\">() \u003C\u002Fspan>\u003Cspan class=\"snCLD\">=&gt;\u003C\u002Fspan>\u003Cspan class=\"sK46n\"> this\u003C\u002Fspan>\u003Cspan class=\"sjLUg\">.\u003C\u002Fspan>\u003Cspan class=\"sFrd5\">planeSpotted\u003C\u002Fspan>\u003Cspan class=\"sjLUg\">.\u003C\u002Fspan>\u003Cspan class=\"sWm5y\">OnCompleted\u003C\u002Fspan>\u003Cspan class=\"sjLUg\">();\n\u003C\u002Fspan>\u003C\u002Fspan>",[100,205,206],{},"So now all the code put together looks like this:",[143,208],{"className":145,"language":146,"meta":147,"style":147,"html":209},"\u003Cspan class=\"line\">\u003Cspan class=\"sJvqV\">public\u003C\u002Fspan>\u003Cspan class=\"s4J9F\"> class\u003C\u002Fspan>\u003Cspan class=\"sw29p\"> JetFighter\n\u003C\u002Fspan>\u003C\u002Fspan>\u003Cspan class=\"line\">\u003Cspan class=\"sjLUg\">{\n\u003C\u002Fspan>\u003C\u002Fspan>\u003Cspan class=\"line\">\u003Cspan class=\"sJvqV\">    private\u003C\u002Fspan>\u003Cspan class=\"sw29p\"> Subject\u003C\u002Fspan>\u003Cspan class=\"sjLUg\">&lt;\u003C\u002Fspan>\u003Cspan class=\"sw29p\">JetFighter\u003C\u002Fspan>\u003Cspan class=\"sjLUg\">&gt; \u003C\u002Fspan>\u003Cspan class=\"sFrd5\">planeSpotted\u003C\u002Fspan>\u003Cspan class=\"snCLD\"> =\u003C\u002Fspan>\u003Cspan class=\"sJvqV\"> new\u003C\u002Fspan>\u003Cspan class=\"sw29p\"> Subject\u003C\u002Fspan>\u003Cspan class=\"sjLUg\">&lt;\u003C\u002Fspan>\u003Cspan class=\"sw29p\">JetFighter\u003C\u002Fspan>\u003Cspan class=\"sjLUg\">&gt;();\n\u003C\u002Fspan>\u003C\u002Fspan>\u003Cspan class=\"line\">\u003Cspan>\n\u003C\u002Fspan>\u003C\u002Fspan>\u003Cspan class=\"line\">\u003Cspan class=\"sJvqV\">    public\u003C\u002Fspan>\u003Cspan class=\"sw29p\"> IObservable\u003C\u002Fspan>\u003Cspan class=\"sjLUg\">&lt;\u003C\u002Fspan>\u003Cspan class=\"sw29p\">JetFighter\u003C\u002Fspan>\u003Cspan class=\"sjLUg\">&gt; \u003C\u002Fspan>\u003Cspan class=\"sFrd5\">PlaneSpotted\u003C\u002Fspan>\u003Cspan class=\"snCLD\"> =&gt;\u003C\u002Fspan>\u003Cspan class=\"sK46n\"> this\u003C\u002Fspan>\u003Cspan class=\"sjLUg\">.\u003C\u002Fspan>\u003Cspan class=\"sFrd5\">planeSpotted\u003C\u002Fspan>\u003Cspan class=\"sjLUg\">;\n\u003C\u002Fspan>\u003C\u002Fspan>\u003Cspan class=\"line\">\u003Cspan>\n\u003C\u002Fspan>\u003C\u002Fspan>\u003Cspan class=\"line\">\u003Cspan class=\"sJvqV\">    public\u003C\u002Fspan>\u003Cspan class=\"sJvqV\"> void\u003C\u002Fspan>\u003Cspan class=\"sWm5y\"> AllPlanesSpotted\u003C\u002Fspan>\u003Cspan class=\"sjLUg\">() \u003C\u002Fspan>\u003Cspan class=\"snCLD\">=&gt;\u003C\u002Fspan>\u003Cspan class=\"sK46n\"> this\u003C\u002Fspan>\u003Cspan class=\"sjLUg\">.\u003C\u002Fspan>\u003Cspan class=\"sFrd5\">planeSpotted\u003C\u002Fspan>\u003Cspan class=\"sjLUg\">.\u003C\u002Fspan>\u003Cspan class=\"sWm5y\">OnCompleted\u003C\u002Fspan>\u003Cspan class=\"sjLUg\">();\n\u003C\u002Fspan>\u003C\u002Fspan>\u003Cspan class=\"line\">\u003Cspan>\n\u003C\u002Fspan>\u003C\u002Fspan>\u003Cspan class=\"line\">\u003Cspan class=\"sJvqV\">    public\u003C\u002Fspan>\u003Cspan class=\"sJvqV\"> void\u003C\u002Fspan>\u003Cspan class=\"sWm5y\"> SpotPlane\u003C\u002Fspan>\u003Cspan class=\"sjLUg\">(\u003C\u002Fspan>\u003Cspan class=\"sw29p\">JetFighter\u003C\u002Fspan>\u003Cspan class=\"sFrd5\"> jetFighter\u003C\u002Fspan>\u003Cspan class=\"sjLUg\">)\n\u003C\u002Fspan>\u003C\u002Fspan>\u003Cspan class=\"line\">\u003Cspan class=\"sjLUg\">    {\n\u003C\u002Fspan>\u003C\u002Fspan>\u003Cspan class=\"line\">\u003Cspan class=\"smL5M\">        try\n\u003C\u002Fspan>\u003C\u002Fspan>\u003Cspan class=\"line\">\u003Cspan class=\"sjLUg\">        {\n\u003C\u002Fspan>\u003C\u002Fspan>\u003Cspan class=\"line\">\u003Cspan class=\"smL5M\">            if\u003C\u002Fspan>\u003Cspan class=\"sjLUg\"> (\u003C\u002Fspan>\u003Cspan class=\"sJvqV\">string\u003C\u002Fspan>\u003Cspan class=\"sjLUg\">.\u003C\u002Fspan>\u003Cspan class=\"sWm5y\">Equals\u003C\u002Fspan>\u003Cspan class=\"sjLUg\">(\u003C\u002Fspan>\u003Cspan class=\"sFrd5\">jetFighter\u003C\u002Fspan>\u003Cspan class=\"sjLUg\">.\u003C\u002Fspan>\u003Cspan class=\"sFrd5\">Name\u003C\u002Fspan>\u003Cspan class=\"sjLUg\">, \u003C\u002Fspan>\u003Cspan class=\"swiDo\">\"UFO\"\u003C\u002Fspan>\u003Cspan class=\"sjLUg\">))\n\u003C\u002Fspan>\u003C\u002Fspan>\u003Cspan class=\"line\">\u003Cspan class=\"sjLUg\">            {\n\u003C\u002Fspan>\u003C\u002Fspan>\u003Cspan class=\"line\">\u003Cspan class=\"smL5M\">                throw\u003C\u002Fspan>\u003Cspan class=\"sJvqV\"> new\u003C\u002Fspan>\u003Cspan class=\"sw29p\"> Exception\u003C\u002Fspan>\u003Cspan class=\"sjLUg\">(\u003C\u002Fspan>\u003Cspan class=\"swiDo\">\"UFO Found\"\u003C\u002Fspan>\u003Cspan class=\"sjLUg\">)\n\u003C\u002Fspan>\u003C\u002Fspan>\u003Cspan class=\"line\">\u003Cspan class=\"sjLUg\">            }\n\u003C\u002Fspan>\u003C\u002Fspan>\u003Cspan class=\"line\">\u003Cspan>\n\u003C\u002Fspan>\u003C\u002Fspan>\u003Cspan class=\"line\">\u003Cspan class=\"sK46n\">            this\u003C\u002Fspan>\u003Cspan class=\"sjLUg\">.\u003C\u002Fspan>\u003Cspan class=\"sFrd5\">planeSpotted\u003C\u002Fspan>\u003Cspan class=\"sjLUg\">.\u003C\u002Fspan>\u003Cspan class=\"sWm5y\">OnNext\u003C\u002Fspan>\u003Cspan class=\"sjLUg\">(\u003C\u002Fspan>\u003Cspan class=\"sFrd5\">jetFighter\u003C\u002Fspan>\u003Cspan class=\"sjLUg\">);\n\u003C\u002Fspan>\u003C\u002Fspan>\u003Cspan class=\"line\">\u003Cspan class=\"sjLUg\">        }\n\u003C\u002Fspan>\u003C\u002Fspan>\u003Cspan class=\"line\">\u003Cspan class=\"smL5M\">        catch\u003C\u002Fspan>\u003Cspan class=\"sjLUg\"> (\u003C\u002Fspan>\u003Cspan class=\"sw29p\">Exception\u003C\u002Fspan>\u003Cspan class=\"sFrd5\"> exception\u003C\u002Fspan>\u003Cspan class=\"sjLUg\">)\n\u003C\u002Fspan>\u003C\u002Fspan>\u003Cspan class=\"line\">\u003Cspan class=\"sjLUg\">        {\n\u003C\u002Fspan>\u003C\u002Fspan>\u003Cspan class=\"line\">\u003Cspan class=\"sK46n\">            this\u003C\u002Fspan>\u003Cspan class=\"sjLUg\">.\u003C\u002Fspan>\u003Cspan class=\"sFrd5\">planeSpotted\u003C\u002Fspan>\u003Cspan class=\"sjLUg\">.\u003C\u002Fspan>\u003Cspan class=\"sWm5y\">OnError\u003C\u002Fspan>\u003Cspan class=\"sjLUg\">(\u003C\u002Fspan>\u003Cspan class=\"sFrd5\">exception\u003C\u002Fspan>\u003Cspan class=\"sjLUg\">);\n\u003C\u002Fspan>\u003C\u002Fspan>\u003Cspan class=\"line\">\u003Cspan class=\"sjLUg\">        }\n\u003C\u002Fspan>\u003C\u002Fspan>\u003Cspan class=\"line\">\u003Cspan class=\"sjLUg\">    }\n\u003C\u002Fspan>\u003C\u002Fspan>\u003Cspan class=\"line\">\u003Cspan class=\"sjLUg\">}\n\u003C\u002Fspan>\u003C\u002Fspan>",[117,211,213,220],{"id":212},"consuming-an-event",[53,214,216],{"href":215,"aria-hidden":123},"#consuming-an-event",[125,217,218],{"xmlns":127,"xmlns:xlink":128,"viewBox":129,"version":130,"width":131,"height":131,"aria-hidden":123},[133,219],{"fill":135,"fill-rule":136,"d":137},"Consuming an Event",[100,222,223],{},"Consuming the Reactive Extensions events is just as easy and this is where you start to see the real benefits of Reactive Extensions. This is how you subscribe and unsubscribe (often forgotten, which can lead to memory leaks) to a standard C# event:",[143,225],{"className":145,"language":146,"meta":147,"style":147,"html":226},"\u003Cspan class=\"line\">\u003Cspan class=\"sJvqV\">public\u003C\u002Fspan>\u003Cspan class=\"s4J9F\"> class\u003C\u002Fspan>\u003Cspan class=\"sw29p\"> BomberControl\u003C\u002Fspan>\u003Cspan class=\"sjLUg\"> : \u003C\u002Fspan>\u003Cspan class=\"sw29p\">IDisposable\n\u003C\u002Fspan>\u003C\u002Fspan>\u003Cspan class=\"line\">\u003Cspan class=\"sjLUg\">{\n\u003C\u002Fspan>\u003C\u002Fspan>\u003Cspan class=\"line\">\u003Cspan class=\"sJvqV\">    private\u003C\u002Fspan>\u003Cspan class=\"sw29p\"> JetFighter\u003C\u002Fspan>\u003Cspan class=\"sFrd5\"> jetfighter\u003C\u002Fspan>\u003Cspan class=\"sjLUg\">;\n\u003C\u002Fspan>\u003C\u002Fspan>\u003Cspan class=\"line\">\u003Cspan>\n\u003C\u002Fspan>\u003C\u002Fspan>\u003Cspan class=\"line\">\u003Cspan class=\"sJvqV\">    public\u003C\u002Fspan>\u003Cspan class=\"sWm5y\"> BomberControl\u003C\u002Fspan>\u003Cspan class=\"sjLUg\">(\u003C\u002Fspan>\u003Cspan class=\"sw29p\">JetFighter\u003C\u002Fspan>\u003Cspan class=\"sFrd5\"> jetFighter\u003C\u002Fspan>\u003Cspan class=\"sjLUg\">) \u003C\u002Fspan>\u003Cspan class=\"snCLD\">=&gt;\n\u003C\u002Fspan>\u003C\u002Fspan>\u003Cspan class=\"line\">\u003Cspan class=\"sFrd5\">        jetfighter\u003C\u002Fspan>\u003Cspan class=\"sjLUg\">.\u003C\u002Fspan>\u003Cspan class=\"sFrd5\">PlaneSpotted\u003C\u002Fspan>\u003Cspan class=\"snCLD\"> +=\u003C\u002Fspan>\u003Cspan class=\"sK46n\"> this\u003C\u002Fspan>\u003Cspan class=\"sjLUg\">.\u003C\u002Fspan>\u003Cspan class=\"sFrd5\">OnPlaneSpotted\u003C\u002Fspan>\u003Cspan class=\"sjLUg\">;\n\u003C\u002Fspan>\u003C\u002Fspan>\u003Cspan class=\"line\">\u003Cspan>\n\u003C\u002Fspan>\u003C\u002Fspan>\u003Cspan class=\"line\">\u003Cspan class=\"sJvqV\">    public\u003C\u002Fspan>\u003Cspan class=\"sJvqV\"> void\u003C\u002Fspan>\u003Cspan class=\"sWm5y\"> Dispose\u003C\u002Fspan>\u003Cspan class=\"sjLUg\">() \u003C\u002Fspan>\u003Cspan class=\"snCLD\">=&gt;\n\u003C\u002Fspan>\u003C\u002Fspan>\u003Cspan class=\"line\">\u003Cspan class=\"sFrd5\">        jetfighter\u003C\u002Fspan>\u003Cspan class=\"sjLUg\">.\u003C\u002Fspan>\u003Cspan class=\"sFrd5\">PlaneSpotted\u003C\u002Fspan>\u003Cspan class=\"snCLD\"> -=\u003C\u002Fspan>\u003Cspan class=\"sK46n\"> this\u003C\u002Fspan>\u003Cspan class=\"sjLUg\">.\u003C\u002Fspan>\u003Cspan class=\"sFrd5\">OnPlaneSpotted\u003C\u002Fspan>\u003Cspan class=\"sjLUg\">;\n\u003C\u002Fspan>\u003C\u002Fspan>\u003Cspan class=\"line\">\u003Cspan>\n\u003C\u002Fspan>\u003C\u002Fspan>\u003Cspan class=\"line\">\u003Cspan class=\"sJvqV\">    private\u003C\u002Fspan>\u003Cspan class=\"sJvqV\"> void\u003C\u002Fspan>\u003Cspan class=\"sWm5y\"> OnPlaneSpotted\u003C\u002Fspan>\u003Cspan class=\"sjLUg\">(\u003C\u002Fspan>\u003Cspan class=\"sJvqV\">object\u003C\u002Fspan>\u003Cspan class=\"sFrd5\"> sender\u003C\u002Fspan>\u003Cspan class=\"sjLUg\">, \u003C\u002Fspan>\u003Cspan class=\"sw29p\">JetFighterEventArgs\u003C\u002Fspan>\u003Cspan class=\"sFrd5\"> e\u003C\u002Fspan>\u003Cspan class=\"sjLUg\">) \u003C\u002Fspan>\u003Cspan class=\"snCLD\">=&gt;\n\u003C\u002Fspan>\u003C\u002Fspan>\u003Cspan class=\"line\">\u003Cspan class=\"sFrd5\">        JetFighter\u003C\u002Fspan>\u003Cspan class=\"sFrd5\"> spottedPlane\u003C\u002Fspan>\u003Cspan class=\"snCLD\"> =\u003C\u002Fspan>\u003Cspan class=\"sFrd5\"> e\u003C\u002Fspan>\u003Cspan class=\"sjLUg\">.\u003C\u002Fspan>\u003Cspan class=\"sFrd5\">SpottedPlane\u003C\u002Fspan>\u003Cspan class=\"sjLUg\">;\n\u003C\u002Fspan>\u003C\u002Fspan>\u003Cspan class=\"line\">\u003Cspan class=\"sjLUg\">}\n\u003C\u002Fspan>\u003C\u002Fspan>",[100,228,229,230,233,234,237],{},"I'm not going to go into it in too much detail, you subscribe using ",[159,231,232],{},"+="," and unsubscribe using ",[159,235,236],{},"-="," operators.",[100,239,240],{},"This is how the same thing can be accomplished using Reactive Extensions:",[143,242],{"className":145,"language":146,"meta":147,"style":147,"html":243},"\u003Cspan class=\"line\">\u003Cspan class=\"sJvqV\">public\u003C\u002Fspan>\u003Cspan class=\"s4J9F\"> class\u003C\u002Fspan>\u003Cspan class=\"sw29p\"> BomberControl\u003C\u002Fspan>\u003Cspan class=\"sjLUg\"> : \u003C\u002Fspan>\u003Cspan class=\"sw29p\">IDisposable\n\u003C\u002Fspan>\u003C\u002Fspan>\u003Cspan class=\"line\">\u003Cspan class=\"sjLUg\">{\n\u003C\u002Fspan>\u003C\u002Fspan>\u003Cspan class=\"line\">\u003Cspan class=\"sJvqV\">    private\u003C\u002Fspan>\u003Cspan class=\"sw29p\"> IDisposable\u003C\u002Fspan>\u003Cspan class=\"sFrd5\"> planeSpottedSubscription\u003C\u002Fspan>\u003Cspan class=\"sjLUg\">;\n\u003C\u002Fspan>\u003C\u002Fspan>\u003Cspan class=\"line\">\u003Cspan>\n\u003C\u002Fspan>\u003C\u002Fspan>\u003Cspan class=\"line\">\u003Cspan class=\"sJvqV\">    public\u003C\u002Fspan>\u003Cspan class=\"sWm5y\"> BomberControl\u003C\u002Fspan>\u003Cspan class=\"sjLUg\">(\u003C\u002Fspan>\u003Cspan class=\"sw29p\">JetFighter\u003C\u002Fspan>\u003Cspan class=\"sFrd5\"> jetFighter\u003C\u002Fspan>\u003Cspan class=\"sjLUg\">) \u003C\u002Fspan>\u003Cspan class=\"snCLD\">=&gt;\n\u003C\u002Fspan>\u003C\u002Fspan>\u003Cspan class=\"line\">\u003Cspan class=\"sK46n\">        this\u003C\u002Fspan>\u003Cspan class=\"sjLUg\">. \u003C\u002Fspan>\u003Cspan class=\"sFrd5\">planeSpottedSubscription\u003C\u002Fspan>\u003Cspan class=\"snCLD\"> =\u003C\u002Fspan>\u003Cspan class=\"sFrd5\"> jetfighter\u003C\u002Fspan>\u003Cspan class=\"sjLUg\">.\u003C\u002Fspan>\u003Cspan class=\"sFrd5\">PlaneSpotted\u003C\u002Fspan>\u003Cspan class=\"sjLUg\">.\u003C\u002Fspan>\u003Cspan class=\"sWm5y\">Subscribe\u003C\u002Fspan>\u003Cspan class=\"sjLUg\">(\u003C\u002Fspan>\u003Cspan class=\"sK46n\">this\u003C\u002Fspan>\u003Cspan class=\"sjLUg\">.\u003C\u002Fspan>\u003Cspan class=\"sFrd5\">OnPlaneSpotted\u003C\u002Fspan>\u003Cspan class=\"sjLUg\">);\n\u003C\u002Fspan>\u003C\u002Fspan>\u003Cspan class=\"line\">\u003Cspan>\n\u003C\u002Fspan>\u003C\u002Fspan>\u003Cspan class=\"line\">\u003Cspan class=\"sJvqV\">    public\u003C\u002Fspan>\u003Cspan class=\"sJvqV\"> void\u003C\u002Fspan>\u003Cspan class=\"sWm5y\"> Dispose\u003C\u002Fspan>\u003Cspan class=\"sjLUg\">() \u003C\u002Fspan>\u003Cspan class=\"snCLD\">=&gt;\n\u003C\u002Fspan>\u003C\u002Fspan>\u003Cspan class=\"line\">\u003Cspan class=\"sK46n\">        this\u003C\u002Fspan>\u003Cspan class=\"sjLUg\">.\u003C\u002Fspan>\u003Cspan class=\"sFrd5\">planeSpottedSubscription\u003C\u002Fspan>\u003Cspan class=\"sjLUg\">.\u003C\u002Fspan>\u003Cspan class=\"sWm5y\">Dispose\u003C\u002Fspan>\u003Cspan class=\"sjLUg\">();\n\u003C\u002Fspan>\u003C\u002Fspan>\u003Cspan class=\"line\">\u003Cspan>\n\u003C\u002Fspan>\u003C\u002Fspan>\u003Cspan class=\"line\">\u003Cspan class=\"sJvqV\">    private\u003C\u002Fspan>\u003Cspan class=\"sJvqV\"> void\u003C\u002Fspan>\u003Cspan class=\"sWm5y\"> OnPlaneSpotted\u003C\u002Fspan>\u003Cspan class=\"sjLUg\">(\u003C\u002Fspan>\u003Cspan class=\"sw29p\">JetFighter\u003C\u002Fspan>\u003Cspan class=\"sFrd5\"> jetFighter\u003C\u002Fspan>\u003Cspan class=\"sjLUg\">) \u003C\u002Fspan>\u003Cspan class=\"snCLD\">=&gt;\n\u003C\u002Fspan>\u003C\u002Fspan>\u003Cspan class=\"line\">\u003Cspan class=\"sFrd5\">        JetFighter\u003C\u002Fspan>\u003Cspan class=\"sFrd5\"> spottedPlane\u003C\u002Fspan>\u003Cspan class=\"snCLD\"> =\u003C\u002Fspan>\u003Cspan class=\"sFrd5\"> jetfighter\u003C\u002Fspan>\u003Cspan class=\"sjLUg\">;\n\u003C\u002Fspan>\u003C\u002Fspan>\u003Cspan class=\"line\">\u003Cspan class=\"sjLUg\">}\n\u003C\u002Fspan>\u003C\u002Fspan>",[100,245,246,247,250,251,254,255,257],{},"The key things to note here are first, the use of the ",[159,248,249],{},"Subscribe"," method to register for plane spotted events. Second, the subscription to the event is stored in an ",[159,252,253],{},"IDisposable"," which can later be disposed of, to un-register from the event. This is where things get interesting, since we now have an ",[159,256,161],{}," we can now use all kinds of Linq queries on it like this:",[143,259],{"className":145,"language":146,"meta":147,"style":147,"html":260},"\u003Cspan class=\"line\">\u003Cspan class=\"sFrd5\">jetfighter\u003C\u002Fspan>\u003Cspan class=\"sjLUg\">.\u003C\u002Fspan>\u003Cspan class=\"sFrd5\">PlaneSpotted\u003C\u002Fspan>\u003Cspan class=\"sjLUg\">.\u003C\u002Fspan>\u003Cspan class=\"sWm5y\">Where\u003C\u002Fspan>\u003Cspan class=\"sjLUg\">(\u003C\u002Fspan>\u003Cspan class=\"sFrd5\">x\u003C\u002Fspan>\u003Cspan class=\"snCLD\"> =&gt;\u003C\u002Fspan>\u003Cspan class=\"sJvqV\"> string\u003C\u002Fspan>\u003Cspan class=\"sjLUg\">.\u003C\u002Fspan>\u003Cspan class=\"sWm5y\">Equals\u003C\u002Fspan>\u003Cspan class=\"sjLUg\">(\u003C\u002Fspan>\u003Cspan class=\"sFrd5\">x\u003C\u002Fspan>\u003Cspan class=\"sjLUg\">.\u003C\u002Fspan>\u003Cspan class=\"sFrd5\">Name\u003C\u002Fspan>\u003Cspan class=\"sjLUg\">, “\u003C\u002Fspan>\u003Cspan class=\"sFrd5\">Eurofighter\u003C\u002Fspan>\u003Cspan class=\"sjLUg\">”)).\u003C\u002Fspan>\u003Cspan class=\"sWm5y\">Subscribe\u003C\u002Fspan>\u003Cspan class=\"sjLUg\">(\u003C\u002Fspan>\u003Cspan class=\"sK46n\">this\u003C\u002Fspan>\u003Cspan class=\"sjLUg\">.\u003C\u002Fspan>\u003Cspan class=\"sFrd5\">OnPlaneSpotted\u003C\u002Fspan>\u003Cspan class=\"sjLUg\">);\n\u003C\u002Fspan>\u003C\u002Fspan>",[100,262,263,264,267,268,272],{},"So in the above line of code, I'm using a Linq query to only register to events where the name of the spotted plane is ",[159,265,266],{},"Eurofighter",". There are a lot more Linq methods you can use but that's beyond the scope of this post and also where you should take a look at ",[53,269,271],{"href":105,"rel":270,"target":110},[107,108,109],"this website",".",[117,274,276,283],{"id":275},"conclusions",[53,277,279],{"href":278,"aria-hidden":123},"#conclusions",[125,280,281],{"xmlns":127,"xmlns:xlink":128,"viewBox":129,"version":130,"width":131,"height":131,"aria-hidden":123},[133,282],{"fill":135,"fill-rule":136,"d":137},"Conclusions",[100,285,286,287,289],{},"Reactive Extensions (Rx) is a pretty large library which does a lot of stuff which overlaps with other libraries like the Task Parallel Library (TPL). It brings no new capabilities but does bring new ways to do things (much like Linq), while writing less code and with more elegance. It can be confusing coming to it as a newcomer, as to where exactly it can be used effectively. Replacing basic events with ",[159,288,161],{}," is definitely one area where we can leverage its power.",[291,292,293],"style",{},"html pre.shiki code .sJvqV, html code.shiki .sJvqV{--shiki-default:#0000FF;--shiki-dark:#F92672}html pre.shiki code .s4J9F, html code.shiki .s4J9F{--shiki-default:#0000FF;--shiki-default-font-style:inherit;--shiki-dark:#66D9EF;--shiki-dark-font-style:italic}html pre.shiki code .sw29p, html code.shiki .sw29p{--shiki-default:#267F99;--shiki-default-text-decoration:inherit;--shiki-dark:#A6E22E;--shiki-dark-text-decoration:underline}html pre.shiki code .sjLUg, html code.shiki .sjLUg{--shiki-default:#000000;--shiki-dark:#F8F8F2}html pre.shiki code .sFrd5, html code.shiki .sFrd5{--shiki-default:#001080;--shiki-dark:#F8F8F2}html pre.shiki code .sWm5y, html code.shiki .sWm5y{--shiki-default:#795E26;--shiki-dark:#A6E22E}html pre.shiki code .snCLD, html code.shiki .snCLD{--shiki-default:#000000;--shiki-dark:#F92672}html pre.shiki code .sK46n, html code.shiki .sK46n{--shiki-default:#0000FF;--shiki-dark:#FD971F}html pre.shiki code .smL5M, html code.shiki .smL5M{--shiki-default:#AF00DB;--shiki-dark:#F92672}html pre.shiki code .sMc8R, html code.shiki .sMc8R{--shiki-default:#0000FF;--shiki-dark:#AE81FF}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html pre.shiki code .swiDo, html code.shiki .swiDo{--shiki-default:#A31515;--shiki-dark:#E6DB74}",{"title":147,"searchDepth":295,"depth":295,"links":296},2,[],{"issue":298,"comments":302},{"number":299,"title":300,"html_url":301},103,"[Comment] Reactive Extensions (Rx) - Part 1 - Replacing C# Events","https:\u002F\u002Fgithub.com\u002FRehanSaeed\u002Frehansaeed.github.io\u002Fissues\u002F103",[303,315,323,331,340,348,356,364,372,380,388,396,404,412,420],{"id":304,"html_url":305,"body_html":306,"created_at":307,"updated_at":307,"author_association":308,"user":309,"reactions":313},627271291,"https:\u002F\u002Fgithub.com\u002FRehanSaeed\u002Frehansaeed.github.io\u002Fissues\u002F103#issuecomment-627271291","\n\u003Cp>\u003Ca target=\"_blank\" rel=\"nofollow noopener noreferrer\" href=\"https:\u002F\u002Fcamo.githubusercontent.com\u002F4408e8a1e4c33f65b5f3609854b45dd86f25405155ccbc343274ad3afd5ff56f\u002F68747470733a2f2f7777772e67726176617461722e636f6d2f6176617461722f36383635373238326566313866343934326338616239313737303537643837363f733d393626643d6d6d26723d67\">\u003Cimg alt=\"Tony\" height=\"40\" width=\"40\" src=\"https:\u002F\u002Fcamo.githubusercontent.com\u002F4408e8a1e4c33f65b5f3609854b45dd86f25405155ccbc343274ad3afd5ff56f\u002F68747470733a2f2f7777772e67726176617461722e636f6d2f6176617461722f36383635373238326566313866343934326338616239313737303537643837363f733d393626643d6d6d26723d67\" \u002F>\u003C\u002Fa> \u003Cstrong>\u003Ca rel=\"nofollow noopener noreferrer\" target=\"_blank\" href=\"http:\u002F\u002Ftonytruong.net\u002F\">Tony\u003C\u002Fa>\u003C\u002Fstrong> commented on \u003Cstrong>2014-10-24 00:36:27\u003C\u002Fstrong>\u003C\u002Fp>\n\u003Cp>Thanks for that. Very helpful in seeing the bigger picture.\u003C\u002Fp>","2020-05-12T11:02:36Z","OWNER",{"login":310,"avatar_url":311,"html_url":312},"RehanSaeed","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F2270364?v=4","https:\u002F\u002Fgithub.com\u002FRehanSaeed",{"url":314,"total_count":4,"+1":4,"-1":4,"laugh":4,"hooray":4,"confused":4,"heart":4,"rocket":4,"eyes":4},"https:\u002F\u002Fapi.github.com\u002Frepos\u002FRehanSaeed\u002Frehansaeed.github.io\u002Fissues\u002Fcomments\u002F627271291\u002Freactions",{"id":316,"html_url":317,"body_html":318,"created_at":319,"updated_at":319,"author_association":308,"user":320,"reactions":321},627271344,"https:\u002F\u002Fgithub.com\u002FRehanSaeed\u002Frehansaeed.github.io\u002Fissues\u002F103#issuecomment-627271344","\n\u003Cp>\u003Ca target=\"_blank\" rel=\"nofollow noopener noreferrer\" href=\"https:\u002F\u002Fcamo.githubusercontent.com\u002Ff85383816c3018f0f39ff929d628b75a9b747a5ecbdd7d9006ae27f834d30100\u002F68747470733a2f2f7777772e67726176617461722e636f6d2f6176617461722f63363061386237636432623439336235613237323437363063343333373037363f733d393626643d6d6d26723d67\">\u003Cimg alt=\"jacob\" height=\"40\" width=\"40\" src=\"https:\u002F\u002Fcamo.githubusercontent.com\u002Ff85383816c3018f0f39ff929d628b75a9b747a5ecbdd7d9006ae27f834d30100\u002F68747470733a2f2f7777772e67726176617461722e636f6d2f6176617461722f63363061386237636432623439336235613237323437363063343333373037363f733d393626643d6d6d26723d67\" \u002F>\u003C\u002Fa> \u003Cstrong>jacob\u003C\u002Fstrong> commented on \u003Cstrong>2014-12-23 17:06:30\u003C\u002Fstrong>\u003C\u002Fp>\n\u003Cp>Great blog! thanks for the help, makes alot more sense now\u003C\u002Fp>","2020-05-12T11:02:43Z",{"login":310,"avatar_url":311,"html_url":312},{"url":322,"total_count":4,"+1":4,"-1":4,"laugh":4,"hooray":4,"confused":4,"heart":4,"rocket":4,"eyes":4},"https:\u002F\u002Fapi.github.com\u002Frepos\u002FRehanSaeed\u002Frehansaeed.github.io\u002Fissues\u002Fcomments\u002F627271344\u002Freactions",{"id":324,"html_url":325,"body_html":326,"created_at":327,"updated_at":327,"author_association":308,"user":328,"reactions":329},627271387,"https:\u002F\u002Fgithub.com\u002FRehanSaeed\u002Frehansaeed.github.io\u002Fissues\u002F103#issuecomment-627271387","\n\u003Cp>\u003Ca target=\"_blank\" rel=\"nofollow noopener noreferrer\" href=\"https:\u002F\u002Fcamo.githubusercontent.com\u002Fd5652105f984dbb5eab267c12479471ad838e94ccd696ea7709ea8a939bf7bd1\u002F68747470733a2f2f7777772e67726176617461722e636f6d2f6176617461722f36326232356463666666333934653765666633303035383335386237353034373f733d393626643d6d6d26723d67\">\u003Cimg alt=\"Abhinav Singh\" height=\"40\" width=\"40\" src=\"https:\u002F\u002Fcamo.githubusercontent.com\u002Fd5652105f984dbb5eab267c12479471ad838e94ccd696ea7709ea8a939bf7bd1\u002F68747470733a2f2f7777772e67726176617461722e636f6d2f6176617461722f36326232356463666666333934653765666633303035383335386237353034373f733d393626643d6d6d26723d67\" \u002F>\u003C\u002Fa> \u003Cstrong>Abhinav Singh\u003C\u002Fstrong> commented on \u003Cstrong>2015-03-06 17:58:38\u003C\u002Fstrong>\u003C\u002Fp>\n\u003Cdiv>\u003Cpre>\u003Cspan>public\u003C\u002Fspan> \u003Cspan>void\u003C\u002Fspan> \u003Cspan>SpotPlane\u003C\u002Fspan>\u003Cspan>(\u003C\u002Fspan>\u003Cspan>JetFighter\u003C\u002Fspan> \u003Cspan>jetFighter\u003C\u002Fspan>\u003Cspan>)\u003C\u002Fspan>\n\u003Cspan>{\u003C\u002Fspan>\n    \u003Cspan>try\u003C\u002Fspan>\n    \u003Cspan>{\u003C\u002Fspan>\n        \u003Cspan>if\u003C\u002Fspan> \u003Cspan>(\u003C\u002Fspan>\u003Cspan>string\u003C\u002Fspan>\u003Cspan>.\u003C\u002Fspan>\u003Cspan>Equals\u003C\u002Fspan>\u003Cspan>(\u003C\u002Fspan>\u003Cspan>jetFighter\u003C\u002Fspan>\u003Cspan>.\u003C\u002Fspan>\u003Cspan>Name\u003C\u002Fspan>\u003Cspan>,\u003C\u002Fspan> \u003Cspan>\"UFO\"\u003C\u002Fspan>\u003Cspan>)\u003C\u002Fspan>\u003Cspan>)\u003C\u002Fspan>\n        \u003Cspan>{\u003C\u002Fspan>\n            \u003Cspan>throw\u003C\u002Fspan> \u003Cspan>new\u003C\u002Fspan> \u003Cspan>Exception\u003C\u002Fspan>\u003Cspan>(\u003C\u002Fspan>\u003Cspan>\"UFO Found\"\u003C\u002Fspan>\u003Cspan>)\u003C\u002Fspan>\n        \u003Cspan>}\u003C\u002Fspan>\n        this\u003Cspan>.\u003C\u002Fspan>\u003Cspan>planeSpotted\u003C\u002Fspan>\u003Cspan>.\u003C\u002Fspan>\u003Cspan>OnNext\u003C\u002Fspan>\u003Cspan>(\u003C\u002Fspan>\u003Cspan>foo\u003C\u002Fspan>\u003Cspan>)\u003C\u002Fspan>\u003Cspan>;\u003C\u002Fspan>\n    \u003Cspan>}\u003C\u002Fspan>\n    \u003Cspan>catch\u003C\u002Fspan> \u003Cspan>(\u003C\u002Fspan>\u003Cspan>Exception\u003C\u002Fspan> \u003Cspan>exception\u003C\u002Fspan>\u003Cspan>)\u003C\u002Fspan>\n    \u003Cspan>{\u003C\u002Fspan>\n        \u003Cspan>this\u003C\u002Fspan>\u003Cspan>.\u003C\u002Fspan>\u003Cspan>planeSpotted\u003C\u002Fspan>\u003Cspan>.\u003C\u002Fspan>\u003Cspan>OnError\u003C\u002Fspan>\u003Cspan>(\u003C\u002Fspan>\u003Cspan>exception\u003C\u002Fspan>\u003Cspan>)\u003C\u002Fspan>\u003Cspan>;\u003C\u002Fspan>\n    \u003Cspan>}\u003C\u002Fspan>\n\u003Cspan>}\u003C\u002Fspan>\u003C\u002Fpre>\u003C\u002Fdiv>\n\u003Cp>In above code, we should have \u003Ccode>this.planeSpotted.OnNext(jetFighter);\u003C\u002Fcode> instead of \u003Ccode>this.planeSpotted.OnNext(foo);\u003C\u002Fcode>?\u003Cbr \u002F>\nMy understanding is correct?\u003Cbr \u002F>\nPlease reply\u003C\u002Fp>","2020-05-12T11:02:50Z",{"login":310,"avatar_url":311,"html_url":312},{"url":330,"total_count":4,"+1":4,"-1":4,"laugh":4,"hooray":4,"confused":4,"heart":4,"rocket":4,"eyes":4},"https:\u002F\u002Fapi.github.com\u002Frepos\u002FRehanSaeed\u002Frehansaeed.github.io\u002Fissues\u002Fcomments\u002F627271387\u002Freactions",{"id":332,"html_url":333,"body_html":334,"created_at":335,"updated_at":336,"author_association":308,"user":337,"reactions":338},627271449,"https:\u002F\u002Fgithub.com\u002FRehanSaeed\u002Frehansaeed.github.io\u002Fissues\u002F103#issuecomment-627271449","\n\u003Cp>\u003Ca target=\"_blank\" rel=\"nofollow noopener noreferrer\" href=\"https:\u002F\u002Fcamo.githubusercontent.com\u002F8a07049df41b8a3839a3f4342f09ea8e6e7fa0065667687f04beca2d088a1dca\u002F68747470733a2f2f7777772e67726176617461722e636f6d2f6176617461722f32623266393030653361633066353535316462646537323864336262343935343f733d393626643d6d6d26723d67\">\u003Cimg alt=\"Muhammad Rehan Saeed\" height=\"40\" width=\"40\" src=\"https:\u002F\u002Fcamo.githubusercontent.com\u002F8a07049df41b8a3839a3f4342f09ea8e6e7fa0065667687f04beca2d088a1dca\u002F68747470733a2f2f7777772e67726176617461722e636f6d2f6176617461722f32623266393030653361633066353535316462646537323864336262343935343f733d393626643d6d6d26723d67\" \u002F>\u003C\u002Fa> \u003Cstrong>\u003Ca rel=\"nofollow noopener noreferrer\" target=\"_blank\" href=\"https:\u002F\u002Frehansaeed.com\u002F\">Muhammad Rehan Saeed\u003C\u002Fa>\u003C\u002Fstrong> commented on \u003Cstrong>2015-03-06 19:15:57\u003C\u002Fstrong>\u003C\u002Fp>\n\u003Cblockquote>\n\u003Cdiv>\u003Cpre>\u003Cspan>public\u003C\u002Fspan> \u003Cspan>void\u003C\u002Fspan> \u003Cspan>SpotPlane\u003C\u002Fspan>\u003Cspan>(\u003C\u002Fspan>\u003Cspan>JetFighter\u003C\u002Fspan> \u003Cspan>jetFighter\u003C\u002Fspan>\u003Cspan>)\u003C\u002Fspan>\n\u003Cspan>{\u003C\u002Fspan>\n    \u003Cspan>try\u003C\u002Fspan>\n    \u003Cspan>{\u003C\u002Fspan>\n        \u003Cspan>if\u003C\u002Fspan> \u003Cspan>(\u003C\u002Fspan>\u003Cspan>string\u003C\u002Fspan>\u003Cspan>.\u003C\u002Fspan>\u003Cspan>Equals\u003C\u002Fspan>\u003Cspan>(\u003C\u002Fspan>\u003Cspan>jetFighter\u003C\u002Fspan>\u003Cspan>.\u003C\u002Fspan>\u003Cspan>Name\u003C\u002Fspan>\u003Cspan>,\u003C\u002Fspan> \u003Cspan>\"UFO\"\u003C\u002Fspan>\u003Cspan>)\u003C\u002Fspan>\u003Cspan>)\u003C\u002Fspan>\n        \u003Cspan>{\u003C\u002Fspan>\n            \u003Cspan>throw\u003C\u002Fspan> \u003Cspan>new\u003C\u002Fspan> \u003Cspan>Exception\u003C\u002Fspan>\u003Cspan>(\u003C\u002Fspan>\u003Cspan>\"UFO Found\"\u003C\u002Fspan>\u003Cspan>)\u003C\u002Fspan>\n        \u003Cspan>}\u003C\u002Fspan>\n        this\u003Cspan>.\u003C\u002Fspan>\u003Cspan>planeSpotted\u003C\u002Fspan>\u003Cspan>.\u003C\u002Fspan>\u003Cspan>OnNext\u003C\u002Fspan>\u003Cspan>(\u003C\u002Fspan>\u003Cspan>foo\u003C\u002Fspan>\u003Cspan>)\u003C\u002Fspan>\u003Cspan>;\u003C\u002Fspan>\n    \u003Cspan>}\u003C\u002Fspan>\n    \u003Cspan>catch\u003C\u002Fspan> \u003Cspan>(\u003C\u002Fspan>\u003Cspan>Exception\u003C\u002Fspan> \u003Cspan>exception\u003C\u002Fspan>\u003Cspan>)\u003C\u002Fspan>\n    \u003Cspan>{\u003C\u002Fspan>\n        \u003Cspan>this\u003C\u002Fspan>\u003Cspan>.\u003C\u002Fspan>\u003Cspan>planeSpotted\u003C\u002Fspan>\u003Cspan>.\u003C\u002Fspan>\u003Cspan>OnError\u003C\u002Fspan>\u003Cspan>(\u003C\u002Fspan>\u003Cspan>exception\u003C\u002Fspan>\u003Cspan>)\u003C\u002Fspan>\u003Cspan>;\u003C\u002Fspan>\n    \u003Cspan>}\u003C\u002Fspan>\n\u003Cspan>}\u003C\u002Fspan>\u003C\u002Fpre>\u003C\u002Fdiv>\n\u003Cp>In above code, we should have \u003Ccode>this.planeSpotted.OnNext(jetFighter);\u003C\u002Fcode> instead of \u003Ccode>this.planeSpotted.OnNext(foo);\u003C\u002Fcode>?\u003Cbr \u002F>\nMy understanding is correct?\u003Cbr \u002F>\nPlease reply\u003C\u002Fp>\n\u003C\u002Fblockquote>\n\u003Cp>Yes that's correct. I've now corrected it.\u003C\u002Fp>","2020-05-12T11:02:57Z","2020-05-12T11:54:33Z",{"login":310,"avatar_url":311,"html_url":312},{"url":339,"total_count":4,"+1":4,"-1":4,"laugh":4,"hooray":4,"confused":4,"heart":4,"rocket":4,"eyes":4},"https:\u002F\u002Fapi.github.com\u002Frepos\u002FRehanSaeed\u002Frehansaeed.github.io\u002Fissues\u002Fcomments\u002F627271449\u002Freactions",{"id":341,"html_url":342,"body_html":343,"created_at":344,"updated_at":344,"author_association":308,"user":345,"reactions":346},627271492,"https:\u002F\u002Fgithub.com\u002FRehanSaeed\u002Frehansaeed.github.io\u002Fissues\u002F103#issuecomment-627271492","\n\u003Cp>\u003Ca target=\"_blank\" rel=\"nofollow noopener noreferrer\" href=\"https:\u002F\u002Fcamo.githubusercontent.com\u002F51f3cb181e7e5588900f79a157b11303ac93e43d0621a567b60ed3425049134d\u002F68747470733a2f2f7777772e67726176617461722e636f6d2f6176617461722f66616564323264626635666464393333633061346131353139623932323338323f733d393626643d6d6d26723d67\">\u003Cimg alt=\"Reader Man\" height=\"40\" width=\"40\" src=\"https:\u002F\u002Fcamo.githubusercontent.com\u002F51f3cb181e7e5588900f79a157b11303ac93e43d0621a567b60ed3425049134d\u002F68747470733a2f2f7777772e67726176617461722e636f6d2f6176617461722f66616564323264626635666464393333633061346131353139623932323338323f733d393626643d6d6d26723d67\" \u002F>\u003C\u002Fa> \u003Cstrong>\u003Ca rel=\"nofollow noopener noreferrer\" target=\"_blank\" href=\"http:\u002F\u002Freaderman1.wordpress.com\u002F\">Reader Man\u003C\u002Fa>\u003C\u002Fstrong> commented on \u003Cstrong>2016-06-04 14:53:49\u003C\u002Fstrong>\u003C\u002Fp>\n\u003Cp>Thanks a lot on this series.\u003C\u002Fp>","2020-05-12T11:03:04Z",{"login":310,"avatar_url":311,"html_url":312},{"url":347,"total_count":4,"+1":4,"-1":4,"laugh":4,"hooray":4,"confused":4,"heart":4,"rocket":4,"eyes":4},"https:\u002F\u002Fapi.github.com\u002Frepos\u002FRehanSaeed\u002Frehansaeed.github.io\u002Fissues\u002Fcomments\u002F627271492\u002Freactions",{"id":349,"html_url":350,"body_html":351,"created_at":352,"updated_at":352,"author_association":308,"user":353,"reactions":354},627271546,"https:\u002F\u002Fgithub.com\u002FRehanSaeed\u002Frehansaeed.github.io\u002Fissues\u002F103#issuecomment-627271546","\n\u003Cp>\u003Ca target=\"_blank\" rel=\"nofollow noopener noreferrer\" href=\"https:\u002F\u002Fcamo.githubusercontent.com\u002F687870a135f2a582765906e66dd7846dd7353ff4a211e3622dcf05c948898b30\u002F68747470733a2f2f7777772e67726176617461722e636f6d2f6176617461722f38353433306331623639346232633161653137313066636634613465663232373f733d393626643d6d6d26723d67\">\u003Cimg alt=\"Sam\" height=\"40\" width=\"40\" src=\"https:\u002F\u002Fcamo.githubusercontent.com\u002F687870a135f2a582765906e66dd7846dd7353ff4a211e3622dcf05c948898b30\u002F68747470733a2f2f7777772e67726176617461722e636f6d2f6176617461722f38353433306331623639346232633161653137313066636634613465663232373f733d393626643d6d6d26723d67\" \u002F>\u003C\u002Fa> \u003Cstrong>Sam\u003C\u002Fstrong> commented on \u003Cstrong>2016-08-17 15:45:07\u003C\u002Fstrong>\u003C\u002Fp>\n\u003Cp>When is this called?\u003C\u002Fp>\n\u003Cdiv>\u003Cpre>\u003Cspan>public\u003C\u002Fspan> \u003Cspan>void\u003C\u002Fspan> \u003Cspan>AllPlanesSpotted\u003C\u002Fspan>\u003Cspan>(\u003C\u002Fspan>\u003Cspan>)\u003C\u002Fspan>\n\u003Cspan>{\u003C\u002Fspan>\n    \u003Cspan>this\u003C\u002Fspan>\u003Cspan>.\u003C\u002Fspan>\u003Cspan>planeSpotted\u003C\u002Fspan>\u003Cspan>.\u003C\u002Fspan>\u003Cspan>OnCompleted\u003C\u002Fspan>\u003Cspan>(\u003C\u002Fspan>\u003Cspan>)\u003C\u002Fspan>\u003Cspan>;\u003C\u002Fspan>\n\u003Cspan>}\u003C\u002Fspan>\u003C\u002Fpre>\u003C\u002Fdiv>","2020-05-12T11:03:12Z",{"login":310,"avatar_url":311,"html_url":312},{"url":355,"total_count":4,"+1":4,"-1":4,"laugh":4,"hooray":4,"confused":4,"heart":4,"rocket":4,"eyes":4},"https:\u002F\u002Fapi.github.com\u002Frepos\u002FRehanSaeed\u002Frehansaeed.github.io\u002Fissues\u002Fcomments\u002F627271546\u002Freactions",{"id":357,"html_url":358,"body_html":359,"created_at":360,"updated_at":360,"author_association":308,"user":361,"reactions":362},627271591,"https:\u002F\u002Fgithub.com\u002FRehanSaeed\u002Frehansaeed.github.io\u002Fissues\u002F103#issuecomment-627271591","\n\u003Cp>\u003Ca target=\"_blank\" rel=\"nofollow noopener noreferrer\" href=\"https:\u002F\u002Fcamo.githubusercontent.com\u002F8a07049df41b8a3839a3f4342f09ea8e6e7fa0065667687f04beca2d088a1dca\u002F68747470733a2f2f7777772e67726176617461722e636f6d2f6176617461722f32623266393030653361633066353535316462646537323864336262343935343f733d393626643d6d6d26723d67\">\u003Cimg alt=\"Muhammad Rehan Saeed\" height=\"40\" width=\"40\" src=\"https:\u002F\u002Fcamo.githubusercontent.com\u002F8a07049df41b8a3839a3f4342f09ea8e6e7fa0065667687f04beca2d088a1dca\u002F68747470733a2f2f7777772e67726176617461722e636f6d2f6176617461722f32623266393030653361633066353535316462646537323864336262343935343f733d393626643d6d6d26723d67\" \u002F>\u003C\u002Fa> \u003Cstrong>\u003Ca rel=\"nofollow noopener noreferrer\" target=\"_blank\" href=\"https:\u002F\u002Frehansaeed.com\u002F\">Muhammad Rehan Saeed\u003C\u002Fa>\u003C\u002Fstrong> commented on \u003Cstrong>2016-08-19 09:18:50\u003C\u002Fstrong>\u003C\u002Fp>\n\u003Cblockquote>\n\u003Cp>When is this called?\u003C\u002Fp>\n\u003Cdiv>\u003Cpre>\u003Cspan>public\u003C\u002Fspan> \u003Cspan>void\u003C\u002Fspan> \u003Cspan>AllPlanesSpotted\u003C\u002Fspan>\u003Cspan>(\u003C\u002Fspan>\u003Cspan>)\u003C\u002Fspan>\n\u003Cspan>{\u003C\u002Fspan>\n    \u003Cspan>this\u003C\u002Fspan>\u003Cspan>.\u003C\u002Fspan>\u003Cspan>planeSpotted\u003C\u002Fspan>\u003Cspan>.\u003C\u002Fspan>\u003Cspan>OnCompleted\u003C\u002Fspan>\u003Cspan>(\u003C\u002Fspan>\u003Cspan>)\u003C\u002Fspan>\u003Cspan>;\u003C\u002Fspan>\n\u003Cspan>}\u003C\u002Fspan>\u003C\u002Fpre>\u003C\u002Fdiv>\n\u003C\u002Fblockquote>\n\u003Cp>I'm just trying to illustrate that observables can have an end, so that no more events are allowed to be raised. It could be called from anywhere.\u003C\u002Fp>","2020-05-12T11:03:19Z",{"login":310,"avatar_url":311,"html_url":312},{"url":363,"total_count":4,"+1":4,"-1":4,"laugh":4,"hooray":4,"confused":4,"heart":4,"rocket":4,"eyes":4},"https:\u002F\u002Fapi.github.com\u002Frepos\u002FRehanSaeed\u002Frehansaeed.github.io\u002Fissues\u002Fcomments\u002F627271591\u002Freactions",{"id":365,"html_url":366,"body_html":367,"created_at":368,"updated_at":368,"author_association":308,"user":369,"reactions":370},627271635,"https:\u002F\u002Fgithub.com\u002FRehanSaeed\u002Frehansaeed.github.io\u002Fissues\u002F103#issuecomment-627271635","\n\u003Cp>\u003Ca target=\"_blank\" rel=\"nofollow noopener noreferrer\" href=\"https:\u002F\u002Fcamo.githubusercontent.com\u002Fcb55fe2d2a62c0daaeab2c15fdc991c02e64610093723ce906e16b0ec66f26c6\u002F68747470733a2f2f7777772e67726176617461722e636f6d2f6176617461722f39346137363139393038343537613563383661663362636261626136366632333f733d393626643d6d6d26723d67\">\u003Cimg alt=\"Andrey\" height=\"40\" width=\"40\" src=\"https:\u002F\u002Fcamo.githubusercontent.com\u002Fcb55fe2d2a62c0daaeab2c15fdc991c02e64610093723ce906e16b0ec66f26c6\u002F68747470733a2f2f7777772e67726176617461722e636f6d2f6176617461722f39346137363139393038343537613563383661663362636261626136366632333f733d393626643d6d6d26723d67\" \u002F>\u003C\u002Fa> \u003Cstrong>Andrey\u003C\u002Fstrong> commented on \u003Cstrong>2017-01-06 12:48:07\u003C\u002Fstrong>\u003C\u002Fp>\n\u003Cp>\"Intro to Rx\" says that using subjects is discouraged, because they are only for playing, they \"introduce mutability\", may have bad performance in future releases, etc.\u003C\u002Fp>\n\u003Cp>The question is: how do I then implement a Rx equivalent of C# events? Implementing a c# event then using \u003Ccode>FromEventPattern\u003C\u002Fcode> seems cumbersome, subjects are \"discouraged\" what do I use then?\u003C\u002Fp>","2020-05-12T11:03:25Z",{"login":310,"avatar_url":311,"html_url":312},{"url":371,"total_count":4,"+1":4,"-1":4,"laugh":4,"hooray":4,"confused":4,"heart":4,"rocket":4,"eyes":4},"https:\u002F\u002Fapi.github.com\u002Frepos\u002FRehanSaeed\u002Frehansaeed.github.io\u002Fissues\u002Fcomments\u002F627271635\u002Freactions",{"id":373,"html_url":374,"body_html":375,"created_at":376,"updated_at":376,"author_association":308,"user":377,"reactions":378},627271678,"https:\u002F\u002Fgithub.com\u002FRehanSaeed\u002Frehansaeed.github.io\u002Fissues\u002F103#issuecomment-627271678","\n\u003Cp>\u003Ca target=\"_blank\" rel=\"nofollow noopener noreferrer\" href=\"https:\u002F\u002Fcamo.githubusercontent.com\u002F8a07049df41b8a3839a3f4342f09ea8e6e7fa0065667687f04beca2d088a1dca\u002F68747470733a2f2f7777772e67726176617461722e636f6d2f6176617461722f32623266393030653361633066353535316462646537323864336262343935343f733d393626643d6d6d26723d67\">\u003Cimg alt=\"Muhammad Rehan Saeed\" height=\"40\" width=\"40\" src=\"https:\u002F\u002Fcamo.githubusercontent.com\u002F8a07049df41b8a3839a3f4342f09ea8e6e7fa0065667687f04beca2d088a1dca\u002F68747470733a2f2f7777772e67726176617461722e636f6d2f6176617461722f32623266393030653361633066353535316462646537323864336262343935343f733d393626643d6d6d26723d67\" \u002F>\u003C\u002Fa> \u003Cstrong>\u003Ca rel=\"nofollow noopener noreferrer\" target=\"_blank\" href=\"https:\u002F\u002Frehansaeed.com\u002F\">Muhammad Rehan Saeed\u003C\u002Fa>\u003C\u002Fstrong> commented on \u003Cstrong>2017-01-07 11:10:34\u003C\u002Fstrong>\u003C\u002Fp>\n\u003Cblockquote>\n\u003Cp>\"Intro to Rx\" says that using subjects is discouraged, because they are only for playing, they \"introduce mutability\", may have bad performance in future releases, etc.\u003C\u002Fp>\n\u003Cp>The question is: how do I then implement a Rx equivalent of C# events? Implementing a c# event then using FromEventPattern seems cumbersome, subjects are \"discouraged\" what do I use then?\u003C\u002Fp>\n\u003C\u002Fblockquote>\n\u003Cp>I've read that too, one of the problems is that you can both publish and subscribe to it which can be dangerous. You hit the nail on the head, how else would you implement events without it? I take the more pragmatic approach. I know the potential pitfalls of using it, I know not to expose the subject outside of the class using it, so I use it.\u003C\u002Fp>","2020-05-12T11:03:32Z",{"login":310,"avatar_url":311,"html_url":312},{"url":379,"total_count":4,"+1":4,"-1":4,"laugh":4,"hooray":4,"confused":4,"heart":4,"rocket":4,"eyes":4},"https:\u002F\u002Fapi.github.com\u002Frepos\u002FRehanSaeed\u002Frehansaeed.github.io\u002Fissues\u002Fcomments\u002F627271678\u002Freactions",{"id":381,"html_url":382,"body_html":383,"created_at":384,"updated_at":384,"author_association":308,"user":385,"reactions":386},627271730,"https:\u002F\u002Fgithub.com\u002FRehanSaeed\u002Frehansaeed.github.io\u002Fissues\u002F103#issuecomment-627271730","\n\u003Cp>\u003Ca target=\"_blank\" rel=\"nofollow noopener noreferrer\" href=\"https:\u002F\u002Fcamo.githubusercontent.com\u002Fcb55fe2d2a62c0daaeab2c15fdc991c02e64610093723ce906e16b0ec66f26c6\u002F68747470733a2f2f7777772e67726176617461722e636f6d2f6176617461722f39346137363139393038343537613563383661663362636261626136366632333f733d393626643d6d6d26723d67\">\u003Cimg alt=\"Andrey\" height=\"40\" width=\"40\" src=\"https:\u002F\u002Fcamo.githubusercontent.com\u002Fcb55fe2d2a62c0daaeab2c15fdc991c02e64610093723ce906e16b0ec66f26c6\u002F68747470733a2f2f7777772e67726176617461722e636f6d2f6176617461722f39346137363139393038343537613563383661663362636261626136366632333f733d393626643d6d6d26723d67\" \u002F>\u003C\u002Fa> \u003Cstrong>Andrey\u003C\u002Fstrong> commented on \u003Cstrong>2017-01-08 13:25:01\u003C\u002Fstrong>\u003C\u002Fp>\n\u003Cblockquote>\n\u003Cp>I've read that too, one of the problems is that you can both publish and subscribe to it which can be dangerous. You hit the nail on the head, how else would you implement events without it? I take the more pragmatic approach. I know the potential pitfalls of using it, I know not to expose the subject outside of the class using it, so I use it.\u003C\u002Fp>\n\u003C\u002Fblockquote>\n\u003Cp>I see, these rumours about subjects are mostly about functional programming ideas. For those who just want a substitute for dumb C# events, \u003Ccode>Subject\u003C\u002Fcode> is just right.\u003C\u002Fp>\n\u003Cp>Found a good explanation on when to use \u003Ccode>Subject\u003C\u002Fcode>:\u003Cbr \u002F>\n\u003Ca rel=\"nofollow noopener noreferrer\" target=\"_blank\" href=\"http:\u002F\u002Fdavesexton.com\u002Fblog\u002Fpost\u002FTo-Use-Subject-Or-Not-To-Use-Subject.aspx\">http:\u002F\u002Fdavesexton.com\u002Fblog\u002Fpost\u002FTo-Use-Subject-Or-Not-To-Use-Subject.aspx\u003C\u002Fa>\u003C\u002Fp>","2020-05-12T11:03:39Z",{"login":310,"avatar_url":311,"html_url":312},{"url":387,"total_count":4,"+1":4,"-1":4,"laugh":4,"hooray":4,"confused":4,"heart":4,"rocket":4,"eyes":4},"https:\u002F\u002Fapi.github.com\u002Frepos\u002FRehanSaeed\u002Frehansaeed.github.io\u002Fissues\u002Fcomments\u002F627271730\u002Freactions",{"id":389,"html_url":390,"body_html":391,"created_at":392,"updated_at":392,"author_association":308,"user":393,"reactions":394},627271784,"https:\u002F\u002Fgithub.com\u002FRehanSaeed\u002Frehansaeed.github.io\u002Fissues\u002F103#issuecomment-627271784","\n\u003Cp>\u003Ca target=\"_blank\" rel=\"nofollow noopener noreferrer\" href=\"https:\u002F\u002Fcamo.githubusercontent.com\u002Fad823f62b334449081f4ba2981c781d98dadc4a0bf1425dcdb4b917b97b8d8e5\u002F68747470733a2f2f7777772e67726176617461722e636f6d2f6176617461722f37386435623636303966653561383063653637653966393731383333613663333f733d393626643d6d6d26723d67\">\u003Cimg alt=\"Jesse Liberty\" height=\"40\" width=\"40\" src=\"https:\u002F\u002Fcamo.githubusercontent.com\u002Fad823f62b334449081f4ba2981c781d98dadc4a0bf1425dcdb4b917b97b8d8e5\u002F68747470733a2f2f7777772e67726176617461722e636f6d2f6176617461722f37386435623636303966653561383063653637653966393731383333613663333f733d393626643d6d6d26723d67\" \u002F>\u003C\u002Fa> \u003Cstrong>\u003Ca rel=\"nofollow noopener noreferrer\" target=\"_blank\" href=\"http:\u002F\u002Fjesseliberty.com\u002F\">Jesse Liberty\u003C\u002Fa>\u003C\u002Fstrong> commented on \u003Cstrong>2017-01-16 14:08:33\u003C\u002Fstrong>\u003C\u002Fp>\n\u003Cp>You may want to take a quick look at \u003Ca rel=\"nofollow noopener noreferrer\" target=\"_blank\" href=\"http:\u002F\u002Fjliberty.me\u002F2j0ePAP\">http:\u002F\u002Fjliberty.me\u002F2j0ePAP\u003C\u002Fa> -- thanks\u003C\u002Fp>","2020-05-12T11:03:46Z",{"login":310,"avatar_url":311,"html_url":312},{"url":395,"total_count":4,"+1":4,"-1":4,"laugh":4,"hooray":4,"confused":4,"heart":4,"rocket":4,"eyes":4},"https:\u002F\u002Fapi.github.com\u002Frepos\u002FRehanSaeed\u002Frehansaeed.github.io\u002Fissues\u002Fcomments\u002F627271784\u002Freactions",{"id":397,"html_url":398,"body_html":399,"created_at":400,"updated_at":400,"author_association":308,"user":401,"reactions":402},627271841,"https:\u002F\u002Fgithub.com\u002FRehanSaeed\u002Frehansaeed.github.io\u002Fissues\u002F103#issuecomment-627271841","\n\u003Cp>\u003Ca target=\"_blank\" rel=\"nofollow noopener noreferrer\" href=\"https:\u002F\u002Fcamo.githubusercontent.com\u002Fa41382bc67b28469c78d7cf834df1e37bdcc6aa6ed8ef160be936275c7280dea\u002F68747470733a2f2f7777772e67726176617461722e636f6d2f6176617461722f62623831346433346432346562326436323562666539623565666239313265643f733d393626643d6d6d26723d67\">\u003Cimg alt=\"HMIndia\" height=\"40\" width=\"40\" src=\"https:\u002F\u002Fcamo.githubusercontent.com\u002Fa41382bc67b28469c78d7cf834df1e37bdcc6aa6ed8ef160be936275c7280dea\u002F68747470733a2f2f7777772e67726176617461722e636f6d2f6176617461722f62623831346433346432346562326436323562666539623565666239313265643f733d393626643d6d6d26723d67\" \u002F>\u003C\u002Fa> \u003Cstrong>\u003Ca rel=\"nofollow noopener noreferrer\" target=\"_blank\" href=\"https:\u002F\u002Fhemantmahajan08.wordpress.com\u002F\">HMIndia\u003C\u002Fa>\u003C\u002Fstrong> commented on \u003Cstrong>2018-10-18 09:01:35\u003C\u002Fstrong>\u003C\u002Fp>\n\u003Cp>In High refresh applications (say Stock market) can we claim that use of RX will improve the performance and memory management\u003C\u002Fp>","2020-05-12T11:03:53Z",{"login":310,"avatar_url":311,"html_url":312},{"url":403,"total_count":4,"+1":4,"-1":4,"laugh":4,"hooray":4,"confused":4,"heart":4,"rocket":4,"eyes":4},"https:\u002F\u002Fapi.github.com\u002Frepos\u002FRehanSaeed\u002Frehansaeed.github.io\u002Fissues\u002Fcomments\u002F627271841\u002Freactions",{"id":405,"html_url":406,"body_html":407,"created_at":408,"updated_at":408,"author_association":308,"user":409,"reactions":410},627271897,"https:\u002F\u002Fgithub.com\u002FRehanSaeed\u002Frehansaeed.github.io\u002Fissues\u002F103#issuecomment-627271897","\n\u003Cp>\u003Ca target=\"_blank\" rel=\"nofollow noopener noreferrer\" href=\"https:\u002F\u002Fcamo.githubusercontent.com\u002F8a07049df41b8a3839a3f4342f09ea8e6e7fa0065667687f04beca2d088a1dca\u002F68747470733a2f2f7777772e67726176617461722e636f6d2f6176617461722f32623266393030653361633066353535316462646537323864336262343935343f733d393626643d6d6d26723d67\">\u003Cimg alt=\"Muhammad Rehan Saeed\" height=\"40\" width=\"40\" src=\"https:\u002F\u002Fcamo.githubusercontent.com\u002F8a07049df41b8a3839a3f4342f09ea8e6e7fa0065667687f04beca2d088a1dca\u002F68747470733a2f2f7777772e67726176617461722e636f6d2f6176617461722f32623266393030653361633066353535316462646537323864336262343935343f733d393626643d6d6d26723d67\" \u002F>\u003C\u002Fa> \u003Cstrong>\u003Ca rel=\"nofollow noopener noreferrer\" target=\"_blank\" href=\"https:\u002F\u002Frehansaeed.com\u002F\">Muhammad Rehan Saeed\u003C\u002Fa>\u003C\u002Fstrong> commented on \u003Cstrong>2018-10-23 09:48:04\u003C\u002Fstrong>\u003C\u002Fp>\n\u003Cblockquote>\n\u003Cp>In High refresh applications (say Stock market) can we claim that use of RX will improve the performance and memory management\u003C\u002Fp>\n\u003C\u002Fblockquote>\n\u003Cp>I don't think you can claim that without building it and measuring the difference.\u003C\u002Fp>","2020-05-12T11:03:59Z",{"login":310,"avatar_url":311,"html_url":312},{"url":411,"total_count":4,"+1":4,"-1":4,"laugh":4,"hooray":4,"confused":4,"heart":4,"rocket":4,"eyes":4},"https:\u002F\u002Fapi.github.com\u002Frepos\u002FRehanSaeed\u002Frehansaeed.github.io\u002Fissues\u002Fcomments\u002F627271897\u002Freactions",{"id":413,"html_url":414,"body_html":415,"created_at":416,"updated_at":416,"author_association":308,"user":417,"reactions":418},627271940,"https:\u002F\u002Fgithub.com\u002FRehanSaeed\u002Frehansaeed.github.io\u002Fissues\u002F103#issuecomment-627271940","\n\u003Cp>\u003Ca target=\"_blank\" rel=\"nofollow noopener noreferrer\" href=\"https:\u002F\u002Fcamo.githubusercontent.com\u002F3430e14ebbdaf0c7e8e14f7681265470028662537f0b6b4f9e8c09a99efeb1eb\u002F68747470733a2f2f7777772e67726176617461722e636f6d2f6176617461722f65393330653831383165336331633662353666383439323432643166373161343f733d393626643d6d6d26723d67\">\u003Cimg alt=\"DanClark\" height=\"40\" width=\"40\" src=\"https:\u002F\u002Fcamo.githubusercontent.com\u002F3430e14ebbdaf0c7e8e14f7681265470028662537f0b6b4f9e8c09a99efeb1eb\u002F68747470733a2f2f7777772e67726176617461722e636f6d2f6176617461722f65393330653831383165336331633662353666383439323432643166373161343f733d393626643d6d6d26723d67\" \u002F>\u003C\u002Fa> \u003Cstrong>DanClark\u003C\u002Fstrong> commented on \u003Cstrong>2019-10-08 21:31:58\u003C\u002Fstrong>\u003C\u002Fp>\n\u003Cp>Hi,\u003C\u002Fp>\n\u003Cp>I followed your example, are you able to answer this question by any chance?\u003Cbr \u002F>\n\u003Ca rel=\"nofollow noopener noreferrer\" target=\"_blank\" href=\"https:\u002F\u002Fstackoverflow.com\u002Fquestions\u002F58263480\u002Freactive-extension-simple-example-not-working-with-number-generator\">https:\u002F\u002Fstackoverflow.com\u002Fquestions\u002F58263480\u002Freactive-extension-simple-example-not-working-with-number-generator\u003C\u002Fa>\u003C\u002Fp>\n\u003Cp>Thanks,\u003C\u002Fp>","2020-05-12T11:04:06Z",{"login":310,"avatar_url":311,"html_url":312},{"url":419,"total_count":4,"+1":4,"-1":4,"laugh":4,"hooray":4,"confused":4,"heart":4,"rocket":4,"eyes":4},"https:\u002F\u002Fapi.github.com\u002Frepos\u002FRehanSaeed\u002Frehansaeed.github.io\u002Fissues\u002Fcomments\u002F627271940\u002Freactions",{"id":421,"html_url":422,"body_html":423,"created_at":424,"updated_at":424,"author_association":308,"user":425,"reactions":426},627271980,"https:\u002F\u002Fgithub.com\u002FRehanSaeed\u002Frehansaeed.github.io\u002Fissues\u002F103#issuecomment-627271980","\n\u003Cp>\u003Ca target=\"_blank\" rel=\"nofollow noopener noreferrer\" href=\"https:\u002F\u002Fcamo.githubusercontent.com\u002F8a07049df41b8a3839a3f4342f09ea8e6e7fa0065667687f04beca2d088a1dca\u002F68747470733a2f2f7777772e67726176617461722e636f6d2f6176617461722f32623266393030653361633066353535316462646537323864336262343935343f733d393626643d6d6d26723d67\">\u003Cimg alt=\"Muhammad Rehan Saeed\" height=\"40\" width=\"40\" src=\"https:\u002F\u002Fcamo.githubusercontent.com\u002F8a07049df41b8a3839a3f4342f09ea8e6e7fa0065667687f04beca2d088a1dca\u002F68747470733a2f2f7777772e67726176617461722e636f6d2f6176617461722f32623266393030653361633066353535316462646537323864336262343935343f733d393626643d6d6d26723d67\" \u002F>\u003C\u002Fa> \u003Cstrong>\u003Ca rel=\"nofollow noopener noreferrer\" target=\"_blank\" href=\"https:\u002F\u002Frehansaeed.com\u002F\">Muhammad Rehan Saeed\u003C\u002Fa>\u003C\u002Fstrong> commented on \u003Cstrong>2019-10-10 20:17:12\u003C\u002Fstrong>\u003C\u002Fp>\n\u003Cblockquote>\n\u003Cp>Hi,\u003C\u002Fp>\n\u003Cp>I followed your example, are you able to answer this question by any chance?\u003Cbr \u002F>\n\u003Ca rel=\"nofollow noopener noreferrer\" target=\"_blank\" href=\"https:\u002F\u002Fstackoverflow.com\u002Fquestions\u002F58263480\u002Freactive-extension-simple-example-not-working-with-number-generator\">https:\u002F\u002Fstackoverflow.com\u002Fquestions\u002F58263480\u002Freactive-extension-simple-example-not-working-with-number-generator\u003C\u002Fa>\u003C\u002Fp>\n\u003Cp>Thanks,\u003C\u002Fp>\n\u003C\u002Fblockquote>\n\u003Cp>That's great! StackOverflow is a great place to ask questions. Have an upvote.\u003C\u002Fp>\n\u003Cp>I had a quick look. You say it doesn't work but don't describe what the problem is, what do you expect and what actually happens.\u003C\u002Fp>","2020-05-12T11:04:13Z",{"login":310,"avatar_url":311,"html_url":312},{"url":427,"total_count":4,"+1":4,"-1":4,"laugh":4,"hooray":4,"confused":4,"heart":4,"rocket":4,"eyes":4},"https:\u002F\u002Fapi.github.com\u002Frepos\u002FRehanSaeed\u002Frehansaeed.github.io\u002Fissues\u002Fcomments\u002F627271980\u002Freactions","2014-02-11T00:00:00+00:00",null,"You should definitely consider using Reactive Extensions (Rx) is as a direct replacement for C# events. This post will explain how.","md",[433,435,436],{"depth":434,"value":138},1,{"depth":434,"value":220},{"depth":434,"value":283},"\u002Fimages\u002Fhero\u002FReactive-Extensions-1366x768.png",{},true,"posts\u002F2014\u002Freactive-extensions-part1-replacing-events\u002Findex",[442,443,444,445,446],".NET","C#","Events","Reactive Extensions","Rx",4,{"left":4,"top":4,"width":26,"height":18,"rotate":4,"vFlip":6,"hFlip":6,"body":449},"\u003Cpath fill=\"currentColor\" d=\"M352 320c-22.608 0-43.387 7.819-59.79 20.895l-102.486-64.054a96.55 96.55 0 0 0 0-41.683l102.486-64.054C308.613 184.181 329.392 192 352 192c53.019 0 96-42.981 96-96S405.019 0 352 0s-96 42.981-96 96c0 7.158.79 14.13 2.276 20.841L155.79 180.895C139.387 167.819 118.608 160 96 160c-53.019 0-96 42.981-96 96s42.981 96 96 96c22.608 0 43.387-7.819 59.79-20.895l102.486 64.054A96.3 96.3 0 0 0 256 416c0 53.019 42.981 96 96 96s96-42.981 96-96s-42.981-96-96-96\"\u002F>",{"left":4,"top":4,"width":18,"height":18,"rotate":4,"vFlip":6,"hFlip":6,"body":451},"\u003Cpath fill=\"currentColor\" d=\"M504 256C504 119 393 8 256 8S8 119 8 256c0 123.78 90.69 226.38 209.25 245V327.69h-63V256h63v-54.64c0-62.15 37-96.48 93.67-96.48c27.14 0 55.52 4.84 55.52 4.84v61h-31.28c-30.8 0-40.41 19.12-40.41 38.73V256h68.78l-11 71.69h-57.78V501C413.31 482.38 504 379.78 504 256\"\u002F>",{"left":4,"top":4,"width":18,"height":18,"rotate":4,"vFlip":6,"hFlip":6,"body":453},"\u003Cpath fill=\"currentColor\" d=\"M459.37 151.716c.325 4.548.325 9.097.325 13.645c0 138.72-105.583 298.558-298.558 298.558c-59.452 0-114.68-17.219-161.137-47.106c8.447.974 16.568 1.299 25.34 1.299c49.055 0 94.213-16.568 130.274-44.832c-46.132-.975-84.792-31.188-98.112-72.772c6.498.974 12.995 1.624 19.818 1.624c9.421 0 18.843-1.3 27.614-3.573c-48.081-9.747-84.143-51.98-84.143-102.985v-1.299c13.969 7.797 30.214 12.67 47.431 13.319c-28.264-18.843-46.781-51.005-46.781-87.391c0-19.492 5.197-37.36 14.294-52.954c51.655 63.675 129.3 105.258 216.365 109.807c-1.624-7.797-2.599-15.918-2.599-24.04c0-57.828 46.782-104.934 104.934-104.934c30.213 0 57.502 12.67 76.67 33.137c23.715-4.548 46.456-13.32 66.599-25.34c-7.798 24.366-24.366 44.833-46.132 57.827c21.117-2.273 41.584-8.122 60.426-16.243c-14.292 20.791-32.161 39.308-52.628 54.253\"\u002F>",{"left":4,"top":4,"width":18,"height":18,"rotate":4,"vFlip":6,"hFlip":6,"body":455},"\u003Cpath fill=\"currentColor\" d=\"M201.5 305.5c-13.8 0-24.9-11.1-24.9-24.6c0-13.8 11.1-24.9 24.9-24.9c13.6 0 24.6 11.1 24.6 24.9c0 13.6-11.1 24.6-24.6 24.6M504 256c0 137-111 248-248 248S8 393 8 256S119 8 256 8s248 111 248 248m-132.3-41.2c-9.4 0-17.7 3.9-23.8 10c-22.4-15.5-52.6-25.5-86.1-26.6l17.4-78.3l55.4 12.5c0 13.6 11.1 24.6 24.6 24.6c13.8 0 24.9-11.3 24.9-24.9s-11.1-24.9-24.9-24.9c-9.7 0-18 5.8-22.1 13.8l-61.2-13.6c-3-.8-6.1 1.4-6.9 4.4l-19.1 86.4c-33.2 1.4-63.1 11.3-85.5 26.8c-6.1-6.4-14.7-10.2-24.1-10.2c-34.9 0-46.3 46.9-14.4 62.8c-1.1 5-1.7 10.2-1.7 15.5c0 52.6 59.2 95.2 132 95.2c73.1 0 132.3-42.6 132.3-95.2c0-5.3-.6-10.8-1.9-15.8c31.3-16 19.8-62.5-14.9-62.5M302.8 331c-18.2 18.2-76.1 17.9-93.6 0c-2.2-2.2-6.1-2.2-8.3 0c-2.5 2.5-2.5 6.4 0 8.6c22.8 22.8 87.3 22.8 110.2 0c2.5-2.2 2.5-6.1 0-8.6c-2.2-2.2-6.1-2.2-8.3 0m7.7-75c-13.6 0-24.6 11.1-24.6 24.9c0 13.6 11.1 24.6 24.6 24.6c13.8 0 24.9-11.1 24.9-24.6c0-13.8-11-24.9-24.9-24.9\"\u002F>",{"left":4,"top":4,"width":18,"height":18,"rotate":4,"vFlip":6,"hFlip":6,"body":457},"\u003Cpath fill=\"currentColor\" d=\"M512 194.8c0 101.3-82.4 183.8-183.8 183.8c-101.7 0-184.4-82.4-184.4-183.8c0-101.6 82.7-184.3 184.4-184.3C429.6 10.5 512 93.2 512 194.8M0 501.5h90v-491H0z\"\u002F>",{"left":4,"top":4,"width":5,"height":5,"rotate":4,"vFlip":6,"hFlip":6,"body":459},"\u003Cpath fill=\"currentColor\" d=\"m20.216 6.415l-.132-.666c-.119-.598-.388-1.163-1.001-1.379c-.197-.069-.42-.098-.57-.241c-.152-.143-.196-.366-.231-.572c-.065-.378-.125-.756-.192-1.133c-.057-.325-.102-.69-.25-.987c-.195-.4-.597-.634-.996-.788a6 6 0 0 0-.626-.194c-1-.263-2.05-.36-3.077-.416a26 26 0 0 0-3.7.062c-.915.083-1.88.184-2.75.5c-.318.116-.646.256-.888.501c-.297.302-.393.77-.177 1.146c.154.267.415.456.692.58c.36.162.737.284 1.123.366c1.075.238 2.189.331 3.287.37q1.829.074 3.65-.118q.449-.05.896-.119c.352-.054.578-.513.474-.834c-.124-.383-.457-.531-.834-.473c-.466.074-.96.108-1.382.146q-1.767.12-3.536.006a22 22 0 0 1-1.157-.107c-.086-.01-.18-.025-.258-.036q-.364-.055-.724-.13c-.111-.027-.111-.185 0-.212h.005q.416-.09.838-.147h.002c.131-.009.263-.032.394-.048a25 25 0 0 1 3.426-.12q1.011.029 2.017.144l.228.031q.4.06.798.145c.392.085.895.113 1.07.542c.055.137.08.288.111.431l.319 1.484a.237.237 0 0 1-.199.284h-.003l-.112.015a37 37 0 0 1-4.743.295a37 37 0 0 1-4.699-.304c-.14-.017-.293-.042-.417-.06c-.326-.048-.649-.108-.973-.161c-.393-.065-.768-.032-1.123.161c-.29.16-.527.404-.675.701c-.154.316-.199.66-.267 1c-.069.34-.176.707-.135 1.056c.087.753.613 1.365 1.37 1.502a39.7 39.7 0 0 0 11.343.376a.483.483 0 0 1 .535.53l-.071.697l-1.018 9.907c-.041.41-.047.832-.125 1.237c-.122.637-.553 1.028-1.182 1.171q-.868.197-1.756.205c-.656.004-1.31-.025-1.966-.022c-.699.004-1.556-.06-2.095-.58c-.475-.458-.54-1.174-.605-1.793l-.731-7.013l-.322-3.094c-.037-.351-.286-.695-.678-.678c-.336.015-.718.3-.678.679l.228 2.185l.949 9.112c.147 1.344 1.174 2.068 2.446 2.272c.742.12 1.503.144 2.257.156c.966.016 1.942.053 2.892-.122c1.408-.258 2.465-1.198 2.616-2.657l1.024-9.995l.215-2.087a.48.48 0 0 1 .39-.426c.402-.078.787-.212 1.074-.518c.455-.488.546-1.124.385-1.766zm-1.478.772c-.145.137-.363.201-.578.233c-2.416.359-4.866.54-7.308.46c-1.748-.06-3.477-.254-5.207-.498c-.17-.024-.353-.055-.47-.18c-.22-.236-.111-.71-.054-.995c.052-.26.152-.609.463-.646c.484-.057 1.046.148 1.526.22q.865.132 1.737.212c2.48.226 5.002.19 7.472-.14q.675-.09 1.345-.21c.399-.072.84-.206 1.08.206c.166.281.188.657.162.974a.54.54 0 0 1-.169.364zm-6.159 3.9c-.862.37-1.84.788-3.109.788a6 6 0 0 1-1.569-.217l.877 9.004c.065.78.717 1.38 1.5 1.38c0 0 1.243.065 1.658.065c.447 0 1.786-.065 1.786-.065c.783 0 1.434-.6 1.499-1.38l.94-9.95a4 4 0 0 0-1.322-.238c-.826 0-1.491.284-2.26.613\"\u002F>",{"left":4,"top":4,"width":29,"height":18,"rotate":4,"vFlip":6,"hFlip":6,"body":461},"\u003Cpath fill=\"currentColor\" d=\"M111.4 295.9c-3.5 19.2-17.4 108.7-21.5 134c-.3 1.8-1 2.5-3 2.5H12.3c-7.6 0-13.1-6.6-12.1-13.9L58.8 46.6c1.5-9.6 10.1-16.9 20-16.9c152.3 0 165.1-3.7 204 11.4c60.1 23.3 65.6 79.5 44 140.3c-21.5 62.6-72.5 89.5-140.1 90.3c-43.4.7-69.5-7-75.3 24.2M357.1 152c-1.8-1.3-2.5-1.8-3 1.3c-2 11.4-5.1 22.5-8.8 33.6c-39.9 113.8-150.5 103.9-204.5 103.9c-6.1 0-10.1 3.3-10.9 9.4c-22.6 140.4-27.1 169.7-27.1 169.7c-1 7.1 3.5 12.9 10.6 12.9h63.5c8.6 0 15.7-6.3 17.4-14.9c.7-5.4-1.1 6.1 14.4-91.3c4.6-22 14.3-19.7 29.3-19.7c71 0 126.4-28.8 142.9-112.3c6.5-34.8 4.6-71.4-23.8-92.6\"\u002F>",{"left":4,"top":4,"width":18,"height":18,"rotate":4,"vFlip":6,"hFlip":6,"body":463},"\u003Cpath fill=\"currentColor\" d=\"M256 8C119.043 8 8 119.083 8 256c0 136.997 111.043 248 248 248s248-111.003 248-248C504 119.083 392.957 8 256 8m0 448c-110.532 0-200-89.431-200-200c0-110.495 89.472-200 200-200c110.491 0 200 89.471 200 200c0 110.53-89.431 200-200 200m107.244-255.2c0 67.052-72.421 68.084-72.421 92.863V300c0 6.627-5.373 12-12 12h-45.647c-6.627 0-12-5.373-12-12v-8.659c0-35.745 27.1-50.034 47.579-61.516c17.561-9.845 28.324-16.541 28.324-29.579c0-17.246-21.999-28.693-39.784-28.693c-23.189 0-33.894 10.977-48.942 29.969c-4.057 5.12-11.46 6.071-16.666 2.124l-27.824-21.098c-5.107-3.872-6.251-11.066-2.644-16.363C184.846 131.491 214.94 112 261.794 112c49.071 0 101.45 38.304 101.45 88.8M298 368c0 23.159-18.841 42-42 42s-42-18.841-42-42s18.841-42 42-42s42 18.841 42 42\"\u002F>",1793000901889]