@bodo:
@roosmaa is correct.
The
instance function takes an object parameter of the type you're binding. Which means that the object must already exist when you bind it.
The
provider takes a function as a parameter, this function must return an object of the type you're binding. It will be called when the type is needed, so the code inside the function is not run at binding time but at injection time.
Note that the example uses the Kotlin's syntax
provider { /* function */ }
which is a syntactic sugar for
provider({ -> /* function */ })
. From this you can see that
provider actually takes a
function argument.