F
F
foonfyrick2021-01-23 08:27:38
Kotlin
foonfyrick, 2021-01-23 08:27:38

callback and listener?

1) I have read that callback is used to get some kind of response from execution, i.e. it is executed after other functions complete, but I can't figure out how to do it with lambda, I can do like this:

fun testLambda(lambda:()->(Unit)){
        lambda()
    }

But is this an implementation of a callback, because if I start several functions in other threads before calling it, then the lambda will not work at all as a callback, it can work out the very first one.
2) Listener is an observer? When I type kotlin listener pattern example I only see pro observer links and examples.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Denis Zagaevsky, 2021-01-23
@foonfyrick

Listener (listener) is a callback (callback), waiting for the onset of some event. The fact that you use a lambda in general is in no way connected with flows, with who will be called before whom. When you call, then it will be.
Listener and Observer is a matter of terminology and naming. Listener and Observer. Essentially one and the same.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question