title: How to unsubscribe events in TornadoFX?
body: <p>In TornadoFX I want to unsubscribe a custom event so that the receiver will never handle the unnecessary events again, and maybe avoid something like memory leaks, however, when I use the <code>unsubscribe&lt;MyEvent&gt;</code> method in my code it doesn't work at all. Here is the part of my code:</p>
  
  <pre><code>object MyEventObj: FXEvent(EventBus.RunOn.BackgroundThread)
  class MyEventBus(val personlist:List&lt;PersonOld&gt;): FXEvent()
  class MyController: Controller()
  {
      init
      {
          subscribe&lt;MyEventObj&gt; {
              unsubscribe&lt;MyEventObj&gt; { 
                  println("Unsubscribe event!") //unsubscrib event and make sure the next code just runs once, but never works!
              }
              println("Event has received!")
              val items = listOf(PersonOld("Name A", 20), PersonOld("Name B", 25))
              fire(MyEventBus(items))
          }
      }
  }
  </code></pre>
  
  <p>So, what is the problem? And how to use <code>unsubscribe</code> in TornadoFX? Thanks for help me in advance!</p>