cache3states<Result, State1, State2, State3> function

Result Function() Function(State1, State2, State3) cache3states<Result, State1, State2, State3>(
  1. Result Function() f(
    1. State1,
    2. State2,
    3. State3
    )
)

Cache for 3 immutable states, and no parameters. Example:

The first time this function is called with some states, it will calculate the result from them, and then return the result. When this function is called again with the same states (compared with the previous ones by IDENTITY) it will return the same result, without having to calculate again. When this function is called again with any of the states (or both) different from the previous ones, it will evict the cache, recalculate the result, and cache it.

var selector = cache3states((List<String> names, int limit, String prefix) =>
       () => names.where((str) => str.startsWith(prefix)).take(limit).toList());

Implementation

Result Function() Function(State1, State2, State3) cache3states<Result, State1, State2, State3>(
  Result Function() Function(State1, State2, State3) f,
) =>
    c.cache3states(f);