Passing ref.read or data itself? #819
Answered
by
rrousselGit
peterhijma
asked this question in
Q&A
-
|
Right now I have these providers, where final userSessionProvider = StateProvider<UserSession?>((ref) => null);
final httpClientProvider = Provider<HttpClient>(
(ref) => HttpClient(
reader: ref.read,
),
);Inside the or ... is it better to pass the final userSessionProvider = StateProvider<UserSession?>((ref) => null);
final httpClientProvider = Provider<HttpClient>(
(ref) => HttpClient(
userSession: ref.watch(userSessionProvider).state,
),
);Or should the final httpClientProvider = Provider<HttpClient>(
(ref) => HttpClient(
token: ref.watch(userSessionProvider).state!.token,
),
);What's best practice here? |
Beta Was this translation helpful? Give feedback.
Answered by
rrousselGit
Oct 15, 2021
Replies: 1 comment 1 reply
-
|
They are all valid. There's no real answer to this question |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
peterhijma
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
They are all valid. There's no real answer to this question