StreamedCache class

StreamedCache

Annotation for Cached package.

Throws an InvalidGenerationSourceError

  • if more then one method is targeting Cached method cache
  • if method return type is incorrect
  • if method has different parameters then target function (excluding Ignore, IgnoreCache)
  • if method is not abstract

Example

Use @StreamedCache annotation:

In this example, cachedStream will return stream of cache updates from cachedMethod

@withCache
abstract mixin class EmitLastValue {
  factory EmitLastValue() = _EmitLastValue;

  @cached
  int cachedMethod() {
    return 1;
  }

  @StreamedCache(methodName: "cachedMethod", emitLastValue: true)
  Stream<int> cachedStream();
}
Annotations
  • @Target.new({TargetKind.method})

Constructors

StreamedCache({required String methodName, bool emitLastValue = false})
PersistentCached
const

Properties

emitLastValue bool
If true, last value from cache (if exists) will be emitted.
final
hashCode int
The hash code for this object.
no setterinherited
methodName String
Name of class method.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited