InsanusMokrassar / ktgbotapi

Type-safe library for work with Telegram Bot API
https://docs.inmo.dev/tgbotapi/index.html
Apache License 2.0
342 stars 29 forks source link

Make MainButton.onClick(() -> Unit) and MainButton.offClick(() -> Unit) public #875

Closed SuLG-ik closed 1 month ago

SuLG-ik commented 1 month ago

Previous public visible function MainButton.onClick(EventHandler) marked as deprecated and can be removed in future

Reason: 1) Usually if MainButton is called, there is WebApp in context. 2) If use MainButton.onClick(EventHandler) there is no way to unregister event listener, because lambda created once and passed same time to MainButton.onClick(() -> Unit), reference to it will be not returned. 3) Without MainButton.offClick(() -> Unit) there is no way to unregister event listener, which is useful in different cases when exist some screens with different MainButton configuration and listener inside.

InsanusMokrassar commented 1 month ago

Hi and thank you for your PR :) I will check it asap