fun {{ receiver }}.{{ name }}(
        context: {{ imported("kotlin.coroutines.CoroutineContext") }} = {{ imported("kotlinx.coroutines.Dispatchers.Main") }},
        {% if (returnType != "Unit") %}returnValue: {{ imported(returnType) }}{% if (returnDefaultValue != "") %} = {{ returnDefaultValue }}{% endif %},
        {% endif %}handler: suspend {{ imported("kotlinx.coroutines.CoroutineScope") }}.({{ args }}) -> Unit
) {
    {{setter}} { {{ argNames }} ->
        {% if (hasArgs == true) -%}
        {{ imported("kotlinx.coroutines.GlobalScope") }}.{{ imported("kotlinx.coroutines.launch") }}(context, {{ imported("kotlinx.coroutines.CoroutineStart.DEFAULT") }}) {
            handler({{ argNames }})
        }
        {%- else -%}
        {{ imported("kotlinx.coroutines.GlobalScope") }}.{{ imported("kotlinx.coroutines.launch") }}(context, {{ imported("kotlinx.coroutines.CoroutineStart.DEFAULT") }}, block = handler)
        {%- endif %}{% if (returnType != "Unit") %}
        returnValue{% endif %}
    }
}

