You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I don't think it's necessary to add something to ViewScope<T> every time we need to use some common values. Also, there should be a way to provide instances as DI does.
Solution
I think in this case we should divide types of instances we provide. So, I propose next types of instances:
static – initializes on application init and never changes (for example, ApplicationInstance)
local – initializes in specific scope (for example, LocalContext that is unique for each view)
mutable – can be changed while program runs (for example, AccountInstance where account can change due to log in / log out)
Providing instances
To provide instance, we use provider function, for example:
Problem
I don't think it's necessary to add something to
ViewScope<T>
every time we need to use some common values. Also, there should be a way to provide instances as DI does.Solution
I think in this case we should divide types of instances we provide. So, I propose next types of instances:
ApplicationInstance
)LocalContext
that is unique for each view)AccountInstance
where account can change due to log in / log out)Providing instances
To provide instance, we use
provider
function, for example:Getting instances
To get instance, we just call corresponding instance in
ViewScope<T>
:It's important to have
ViewScope<T>
, because it storesinstanceProvider: InstanceProvder
.The text was updated successfully, but these errors were encountered: