Skip to content

Commit

Permalink
refactor: Simplify schedule data source provider middleware implement…
Browse files Browse the repository at this point in the history
…ation
  • Loading branch information
0niel committed Feb 5, 2025
1 parent 0c684b4 commit bda3178
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions api/lib/src/middleware/schedule_data_source_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,11 @@ import 'package:university_app_server_api/src/redis.dart';
final _delegate = RtuMireaScheduleDataSource();

Middleware scheduleDataSourceProvider() {
return (handler) {
return (context) async {
final redis = context.read<RedisClient>();
final dataSource = CachedScheduleDataSource(
delegate: _delegate,
redisClient: redis,
);
return handler.use(provider<ScheduleDataSource>((_) => dataSource))(context);
};
};
return provider<ScheduleDataSource>((context) {
final redis = context.read<RedisClient>();
return CachedScheduleDataSource(
delegate: _delegate,
redisClient: redis,
);
});
}

0 comments on commit bda3178

Please sign in to comment.