https://kotlinlang.org logo
Title
c

ClaudiuB

11/09/2018, 5:58 AM
How should the
Stateful by state()
part of this should be interpreted?
class MySuperCoolActivity : Activity(), Stateful by state()
and
state()
is a global function
k

karelpeeters

11/09/2018, 6:43 AM
What is
Stateful
?
h

hho

11/09/2018, 8:25 AM
Stateful
is an interface, and
MySuperCoolActivity
implements that interface by delegating all calls to whatever
state()
returns.
c

ClaudiuB

11/09/2018, 8:39 AM
Yes, `Stateful`is an interface, and
state()
is a function that returns an implementation of
state()
. The example I was looking at showed that you could then call functions of
Stateful
in your
MySuperCoolActivity
. Means you can offload implementation of interfaces to other classes while still keeping the ability to directly call the functions, neat!