Skip to content

Commit

Permalink
feat: SingleStreamProvider
Browse files Browse the repository at this point in the history
  • Loading branch information
Gustl22 committed Jan 16, 2024
1 parent ff7186b commit 0e8b298
Show file tree
Hide file tree
Showing 12 changed files with 572 additions and 241 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions wrestling_scoreboard_client/lib/provider/data_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,22 @@ import 'package:wrestling_scoreboard_common/common.dart';

part 'data_provider.g.dart';

@riverpod
Stream<T> singleDataStream<T extends DataObject>(
SingleDataStreamRef ref, {
required int id,
T? initialData,
}) {
// Reload, whenever the stream connects or disconnects
// TODO: integrate in updating websocket URL from stream provider
ref.watch(webSocketStateStreamProvider);

// ref.onDispose(webSocketConnectionStream.close);
// TODO: e.g. may be triggered twice
return dataProvider
.streamSingle<T>(id, init: initialData == null);
}

@riverpod
Stream<List<T>> manyDataStream<T extends DataObject, S extends DataObject?>(
ManyDataStreamRef ref, {
Expand Down
Loading

0 comments on commit 0e8b298

Please sign in to comment.