-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add utilities for fetching lists of entities
- Loading branch information
1 parent
20443f1
commit 6f43818
Showing
2 changed files
with
12 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import 'package:nyxx/nyxx.dart'; | ||
|
||
/// Extensions for fetching lists of [SnowflakeEntity]s. | ||
extension PartialList<T extends SnowflakeEntity<T>> | ||
on List<SnowflakeEntity<T>> { | ||
/// Get all the entities in this list using the cached entity if possible. | ||
Future<List<T>> get() => Future.wait(map((entity) => entity.get())); | ||
|
||
/// Fetch all the entities in this list. | ||
Future<List<T>> fetch() => Future.wait(map((entity) => entity.fetch())); | ||
} |