Question: I have built a Cordova alarm clock app that has a timer. Everything works good except that I now want to inform the user when the clock is up with a visual and audio alarm.

I have used the following plugin for local notifications: <https://github.com/katzer/cordova-plugin-local-notifications>

This seems to work good except that it doesn't seem to work when the phone screen is off.

Any ideas of a better way of doing this. I probably want something like AlarmManager in Android but so far I haven't found a Cordova plugin for it.

Answer: 
This is easily solved using [RxSwift](https://github.com/ReactiveX/RxSwift "RxSwift/RxCocoa")

```
import RxSwift
import RxCocoa

...

@IBOutlet weak var button:UIButton!

...

let taps = button.rx.tap.asDriver() 

taps.drive(onNext: {
    // handle tap
})

```

---

**Edit**: 

I wanted to acknowledge that RxSwift/RxCocoa is a pretty heavy-weight dependency to add to a project just to solve this one requirement. There may be lighter-weight solutions available or just stick with target/action pattern. 

In any case, if the idea of a general purpose declarative approach to handling application and user events appeals to you, definitely give RxSwift a look. It's the bomb.
UIButton inherits from UIControl, which handles the receiving of input and forwarding to the selection. According to the docs, the action is "A selector identifying an action message. It cannot be NULL." And a Selector is strictly a pointer to a method. 

I would think that given the emphases Swift seems to be placing on Closures, this would be possible, but this doesnt seem to be the case.