I was wondering how can I test the logic of the entity that will use RxKeyboard (as it is a singleton), and thought this could be a great addition to RxKeyboard.
Having it conform to such protocol, will make mocking very easy, and one could just inject RxKeyboard.instance as a dependancy or the mock for the tests instead of just using the global instance:
protocol RxKeyboarding {
/// An observable keyboard frame.
var frame: Driver<CGRect> { get }
/// An observable visible height of keyboard. Emits keyboard height if the keyboard is visible
/// or `0` if the keyboard is not visible.
var visibleHeight: Driver<CGFloat> { get }
/// Same with `visibleHeight` but only emits values when keyboard is about to show. This is
/// useful when adjusting scroll view content offset.
var willShowVisibleHeight: Driver<CGFloat> { get }
}
I was wondering how can I test the logic of the entity that will use
RxKeyboard
(as it is a singleton), and thought this could be a great addition toRxKeyboard
.Having it conform to such protocol, will make mocking very easy, and one could just inject
RxKeyboard.instance
as a dependancy or the mock for the tests instead of just using the global instance: