Skip to content

Instantly share code, notes, and snippets.

View fergusonm's full-sized avatar

Michael Ferguson fergusonm

View GitHub Profile
@fergusonm
fergusonm / gist:fb1da641246bd68275597561baa636e7
Last active September 26, 2022 08:01
Single Live Event Stream Sample
class MainViewModel : ViewModel() {
sealed class Event {
object NavigateToSettings: Event()
data class ShowSnackBar(val text: String): Event()
data class ShowToast(val text: String): Event()
}
private val eventChannel = Channel<Event>(Channel.BUFFERED)
val eventsFlow = eventChannel.receiveAsFlow()
@fergusonm
fergusonm / gist:bc12dfe20562389c6064c1efa158ce66
Created September 3, 2019 14:29
Method level logging live template. Logs the method name with all arguments.
Saved as "mlog" with Kotlin statement applicability. (Obviously change to suit your own needs.)
android.util.Log.d("LOGLOGLOG", "$className$ $METHOD_NAME$() called with: " + $args$)
Params:
classname - kotlinClassName()
METHOD_NAME - kotlinFunctionName()
args - groovyScript("'\"' + _1.collect { it + ' = [\" + ' + it + ' + \"]'}.join(', ') + '\"'", functionParameters())