title: Timer doesn't work in native react-native component
body: <p>In my JavaScript, I'm calling a <code>start</code> method on some swift code:</p>
  
  <pre><code>import {NativeModules} from "react-native";
  
  // somewhere in JS
  NativeModules.MyTestClass.start();
  // somewhere else I'm listening for events from the swift code
  const myModule = new NativeEventEmitter(NativeModules.MyTestClass);
  const subscription = myModule.addListener("testEvent", message =&gt; {
    console.log(message);
  });
  </code></pre>
  
  <p>Swift code:</p>
  
  <pre><code>import Foundation
  
  @objc(MyTestClass)
  class MyTestClass: RCTEventEmitter {
    let testEventName = "testEvent"
  
    override func supportedEvents() -&gt; [String]! {
      return [testEventName]
    }
  
    @objc func start() -&gt; Void {
      let timer = Timer.scheduledTimer(
          timeInterval: 0.1,
          target: self,
          selector: #selector(self.update),
          userInfo: nil,
          repeats: true)
      RunLoop.main.add(timer, forMode: RunLoopMode.commonModes)
    }
  
    @objc func update() {
      print("test")
      self.sendToJs(message: "test")
    }
  
    @objc private func sendToJs(message: String) -&gt; Void {
      self.sendEvent(withName: testEventName, body: message)
    }
  }
  </code></pre>
  
  <p>...which starts up a timer and then, in this example, repeatedly sends the same message to my JavaScript code listening for the event.</p>
  
  <p><strong>Problem:</strong> The <code>update</code> method is never called even when adding the timer to the main run loop as outlined in <a href="https://stackoverflow.com/questions/31915024/nstimer-is-not-fired-in-react-native-component">this answer</a>.</p>
  
  <p>Is there a simple mistake I'm making here? I'm new to swift.</p>
  
  <p>If not, I'll have to move the timer to JS then repeatedly call the swift code for the data... I'd rather not do that because in my real scenario the timer sending back data is conditional, but I guess doing that is not too bad...</p>