Is initalValue argument preserved? #94
-
Having this: extension _ConvenienceExtension on SideEffectRegistrar {
SideEffectRegistrar get use => this;
}
extension SideEffectRegistrarExtension on SideEffectRegistrar {
CachedValueController<T> cachedValue<T extends Object?>(T initial) {
final (state, setState) = use.state<T>(initial);
return (
value: state,
set: setState,
reset: () => setState(initial),
modified: () => state != initial,
);
}
}
typedef CachedValueController<T extends Object?> = ({
T value,
void Function(T) set,
void Function() reset,
bool Function() modified,
});
Is this correct or must I save |
Beta Was this translation helpful? Give feedback.
Answered by
GregoryConrad
Feb 3, 2024
Replies: 2 comments
-
I suppose it is okay like this. Maybe too silly question |
Beta Was this translation helpful? Give feedback.
0 replies
-
It’s up to you how you want to do it. Either or would work fine, but a use.value would guarantee that anything new passed in is ignored. BTW, |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
busslina
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It’s up to you how you want to do it. Either or would work fine, but a use.value would guarantee that anything new passed in is ignored.
BTW,
T extends Object?
Is redundant, you can just use<T>
. And also you don’t need to wrapmodified
with a closure, you can just return abool modified
.