Skip to content

Commit c016331

Browse files
committed
doc(memo): Improve memo documentation.
1 parent cfa8432 commit c016331

3 files changed

Lines changed: 11 additions & 11 deletions

File tree

packages/reactter/lib/src/memo/interceptors/async_memo_safe.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
part of '../../memo.dart';
22

3-
/// It's a memoization interceptor that removes memoized values
4-
/// if its futures that throw an error when executed.
3+
/// It's a memoization interceptor that prevents saving in cache
4+
/// if the `Future` calculation function throws an error when executed.
55
class AsyncMemoSafe<T, A> extends MemoInterceptor<T, A> {
66
const AsyncMemoSafe();
77

packages/reactter/lib/src/memo/interceptors/memo_interceptor.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
part of '../../memo.dart';
22

3-
/// It allows for intercepting and memoizing function calls.
3+
/// It allows for intercepting the memoizing function calls.
44
abstract class MemoInterceptor<T, A> {
55
const MemoInterceptor();
66

packages/reactter/lib/src/memo/memo.dart

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,20 +39,20 @@ class Memo<T, A> {
3939
final _cache = HashMap<int, T>();
4040

4141
/// It's used to store the function that will be memoized.
42-
final FunctionArg<T, A> _calculateValue;
42+
final FunctionArg<T, A> _computeValue;
4343

4444
/// It allows you to provide a custom interceptor object that can intercept
4545
/// and handle various events during the memoization process.
4646
final MemoInterceptor<T, A>? _interceptor;
4747

4848
Memo(
49-
FunctionArg<T, A> calculateValue, [
49+
FunctionArg<T, A> computeValue, [
5050
MemoInterceptor<T, A>? interceptor,
51-
]) : _calculateValue = calculateValue,
51+
]) : _computeValue = computeValue,
5252
_interceptor = interceptor;
5353

5454
/// Creates a memoized function version. It´s used for memoizing values([T])
55-
/// returned by a calcutate function([calculateValue]).
55+
/// returned by a calcutate function([computeValue]).
5656
///
5757
/// This is a factorial example:
5858
///
@@ -87,12 +87,12 @@ class Memo<T, A> {
8787
/// See also:
8888
///
8989
/// * [Args], a class which represents the arguments received by
90-
/// the function([calculateValue]), and also used as a cache value binding.
90+
/// the function([computeValue]), and also used as a cache value binding.
9191
static FunctionMemo<T, A> inline<T, A>(
92-
FunctionArg<T, A> calculateValue, [
92+
FunctionArg<T, A> computeValue, [
9393
MemoInterceptor<T, A>? interceptor,
9494
]) =>
95-
Memo<T, A>(calculateValue, interceptor).call;
95+
Memo<T, A>(computeValue, interceptor).call;
9696

9797
/// Invokes the [calculateValue] with the given [arg],
9898
/// then stores and returns the resolved value.
@@ -116,7 +116,7 @@ class Memo<T, A> {
116116
}
117117

118118
try {
119-
final valueCalculated = _calculateValue(arg);
119+
final valueCalculated = _computeValue(arg);
120120

121121
_cache[arg.hashCode] = valueCalculated;
122122

0 commit comments

Comments
 (0)