LouisCAD / Splitties

A collection of hand-crafted extensions for your Kotlin projects.

Home Page:https://splitties.louiscad.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add suspend listeners like those from Anko

domyn opened this issue · comments

Hi, it would be great to have suspend listeners like those from Anko (see here) available in e.g. Views Coroutine splittie. Could you add those please?

Hi, these break structured concurrency, which is not a practice I'm encouraging because it can very easily lead to memory, computational or listener leaks (or all of these).

That said, Splitties already has awaitOneClick() extension function for View in the Views Coroutines split, which allows you to integrate click listening neatly in your suspending function, and disable the button once clicked, until your code is ready to handle a newer click (using a loop, or a flow collector for example).

This is a different approach, but I believe it's better that what Anko listeners offered in terms of design and risks involved.