How should the `Stateful by state()` part of this ...
# getting-started
c
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
What is
Stateful
?
h
Stateful
is an interface, and
MySuperCoolActivity
implements that interface by delegating all calls to whatever
state()
returns.
c
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!