|
|
|
@ -13,16 +13,10 @@ inline fun <reified EVENT> postEvent(tag: String, event: EVENT) { |
|
|
|
|
LiveEventBus.get().with(tag, EVENT::class.java).post(event) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
inline fun <reified EVENT> AppCompatActivity.observeEvent(tag: String, crossinline observer: (EVENT) -> Unit) { |
|
|
|
|
eventObservable<EVENT>(tag).observe(this, Observer { |
|
|
|
|
observer(it) |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 只能观察相同类型的事件,可用EventMessage |
|
|
|
|
*/ |
|
|
|
|
inline fun <reified EVENT> AppCompatActivity.observeEvents(vararg tags: String, crossinline observer: (EVENT) -> Unit) { |
|
|
|
|
inline fun <reified EVENT> AppCompatActivity.observeEvent( |
|
|
|
|
vararg tags: String, |
|
|
|
|
noinline observer: (EVENT) -> Unit |
|
|
|
|
) { |
|
|
|
|
val o = Observer<EVENT> { |
|
|
|
|
observer(it) |
|
|
|
|
} |
|
|
|
@ -31,15 +25,10 @@ inline fun <reified EVENT> AppCompatActivity.observeEvents(vararg tags: String, |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
inline fun <reified EVENT> AppCompatActivity.observeEventSticky(tag: String, crossinline observer: (EVENT) -> Unit) { |
|
|
|
|
eventObservable<EVENT>(tag).observeSticky(this, Observer { |
|
|
|
|
observer(it) |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
inline fun <reified EVENT> AppCompatActivity.observeEventsSticky( |
|
|
|
|
inline fun <reified EVENT> AppCompatActivity.observeEventSticky( |
|
|
|
|
vararg tags: String, |
|
|
|
|
crossinline observer: (EVENT) -> Unit |
|
|
|
|
noinline observer: (EVENT) -> Unit |
|
|
|
|
) { |
|
|
|
|
val o = Observer<EVENT> { |
|
|
|
|
observer(it) |
|
|
|
@ -49,13 +38,10 @@ inline fun <reified EVENT> AppCompatActivity.observeEventsSticky( |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
inline fun <reified EVENT> Fragment.observeEvent(tag: String, crossinline observer: (EVENT) -> Unit) { |
|
|
|
|
eventObservable<EVENT>(tag).observe(this, Observer { |
|
|
|
|
observer(it) |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
inline fun <reified EVENT> Fragment.observeEvents(vararg tags: String, crossinline observer: (EVENT) -> Unit) { |
|
|
|
|
inline fun <reified EVENT> Fragment.observeEvent( |
|
|
|
|
vararg tags: String, |
|
|
|
|
noinline observer: (EVENT) -> Unit |
|
|
|
|
) { |
|
|
|
|
val o = Observer<EVENT> { |
|
|
|
|
observer(it) |
|
|
|
|
} |
|
|
|
@ -64,13 +50,10 @@ inline fun <reified EVENT> Fragment.observeEvents(vararg tags: String, crossinli |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
inline fun <reified EVENT> Fragment.observeEventSticky(tag: String, crossinline observer: (EVENT) -> Unit) { |
|
|
|
|
eventObservable<EVENT>(tag).observeSticky(this, Observer { |
|
|
|
|
observer(it) |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
inline fun <reified EVENT> Fragment.observeEventsSticky(vararg tags: String, crossinline observer: (EVENT) -> Unit) { |
|
|
|
|
inline fun <reified EVENT> Fragment.observeEventSticky( |
|
|
|
|
vararg tags: String, |
|
|
|
|
noinline observer: (EVENT) -> Unit |
|
|
|
|
) { |
|
|
|
|
val o = Observer<EVENT> { |
|
|
|
|
observer(it) |
|
|
|
|
} |
|
|
|
@ -78,3 +61,4 @@ inline fun <reified EVENT> Fragment.observeEventsSticky(vararg tags: String, cro |
|
|
|
|
eventObservable<EVENT>(it).observeSticky(this, o) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|