Binding onDidXXX listeners


Greetings. I am not sure if this is a question about the specific atom-listeners onDidxxx or just me not understanding coffeescript. Below is a minimal example. you can e.g. put it in your and call the test command. I believe that my problem below is caused by not binding the listeners, but i don’t see how to solve it. Wrapping the anonymous function with .bind(this) does not work.

     {TextEditor, Disposable, Range, Point, Atom} = require 'atom'
    class TestGuy
      constructor:(range,id) ->
        editor = atom.workspace.getActiveTextEditor()
        @marker = editor.markBufferRange(range)
        @id = id

    class TestGuys
      constructor:() ->
        @markID = 0
        @disposables = []

      bundle:() ->
        for i in [0...2]
          testguy = new TestGuy([[i,0],[i,5]],@markID)
          console.log( #prints 0,1 as i expect
          @markID += 1
          @disposables.push testguy.marker.onDidChange (event) =>
            console.log( #when i invalidate them, they print 1,1, and i expected 0,1 !

    atom.commands.add 'atom-text-editor', 'custom:test', ->
      testobject = new TestGuys()