-
Notifications
You must be signed in to change notification settings - Fork 11
Open
Description
Problem
I have some Repository classes that need to do some initialization beyond simply assigning properties (e.g. setting up a subscription to a stream, for example). I can't seem to figure out how to do this with cached as my class becomes a mixin which can't have a constructor.
Is there a pattern here I'm missing?
Desired Solution
I want to be able to pass in stuff and still used cached, such as a repository class that looks like the following:
class FooRepository
{
final ApiClient client;
late final StreamSubscription<foo> _fooSub;
FooRepository({
required this.client
required Stream<foo> fooStream;
})
{
_fooSub = fooStream.listen((foo f) { /* ... */ });
}
/* ... some methods that might care about `fooStream` ... */
/* ... methods that use `client` that I want to be able to easily cache ... */
}
Alternatives Considered
I couldn't figure out a pattern that allowed me to do this, without creating additional messes. I just want to use Cached for some methods in the repository, which also requires some data from streams for performance reasons.
On which platorm do you expect this solution?
All
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels