mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2024-11-22 00:03:48 +00:00
fixes in viewport changed events
This commit is contained in:
parent
040a996df6
commit
fbc5e9f8c4
@ -1,4 +1,4 @@
|
|||||||
package dev.inmo.tgbotapi.webapps
|
package dev.inmo.tgbotapi.webapps
|
||||||
|
|
||||||
typealias EventHandler = WebApp.() -> Unit
|
typealias EventHandler = WebApp.() -> Unit
|
||||||
typealias ViewportChangedEventHandler = WebApp.(Boolean) -> Unit
|
typealias ViewportChangedEventHandler = WebApp.(ViewportChangedData) -> Unit
|
||||||
|
@ -0,0 +1,5 @@
|
|||||||
|
package dev.inmo.tgbotapi.webapps
|
||||||
|
|
||||||
|
external interface ViewportChangedData {
|
||||||
|
val isStateStable: Boolean
|
||||||
|
}
|
@ -19,11 +19,11 @@ external class WebApp {
|
|||||||
|
|
||||||
internal fun onEvent(type: String, callback: () -> Unit)
|
internal fun onEvent(type: String, callback: () -> Unit)
|
||||||
@JsName("onEvent")
|
@JsName("onEvent")
|
||||||
internal fun onEventWithBoolean(type: String, callback: (Boolean) -> Unit)
|
internal fun onEventWithBoolean(type: String, callback: (ViewportChangedData) -> Unit)
|
||||||
|
|
||||||
fun offEvent(type: String, callback: () -> Unit)
|
fun offEvent(type: String, callback: () -> Unit)
|
||||||
@JsName("offEvent")
|
@JsName("offEvent")
|
||||||
fun offEventWithBoolean(type: String, callback: (Boolean) -> Unit)
|
fun offEventWithBoolean(type: String, callback: (ViewportChangedData) -> Unit)
|
||||||
|
|
||||||
fun sendData(data: String)
|
fun sendData(data: String)
|
||||||
|
|
||||||
@ -54,7 +54,7 @@ fun WebApp.onEvent(type: EventType, eventHandler: EventHandler) = {
|
|||||||
/**
|
/**
|
||||||
* @return The callback which should be used in case you want to turn off events handling
|
* @return The callback which should be used in case you want to turn off events handling
|
||||||
*/
|
*/
|
||||||
fun WebApp.onEvent(type: EventType.ViewportChanged, eventHandler: ViewportChangedEventHandler) = { it: Boolean ->
|
fun WebApp.onEvent(type: EventType.ViewportChanged, eventHandler: ViewportChangedEventHandler) = { it: ViewportChangedData ->
|
||||||
eventHandler(js("this").unsafeCast<WebApp>(), it)
|
eventHandler(js("this").unsafeCast<WebApp>(), it)
|
||||||
}.also {
|
}.also {
|
||||||
onEventWithBoolean(
|
onEventWithBoolean(
|
||||||
|
Loading…
Reference in New Issue
Block a user