cache1state<Result, State1> function Null safety

Result? Function() Function(State1) cache1state<Result, State1>(
  1. Result Function() f(
    1. State1
    )
)

Cache for 1 immutable state, and no parameters.

The first time this function is called with some state, it will calculate the result from it, and then return the result. When this function is called again with the same state (compared with the previous one by identity) it will return the same result, without having to calculate again. When this function is called again with a different from the previous one, it will evict the cache, recalculate the result, and cache it.

Example:

var selector = cache1((int limit) =>
   () =>
   stateNames.take(limit).toList());

Implementation

Result? Function() Function(State1) cache1state<Result, State1>(
  Result Function() Function(State1) f,
) =>
    c.cache1state(f);