File tree Expand file tree Collapse file tree 1 file changed +44
-0
lines changed
patterns/iterator/github_commit Expand file tree Collapse file tree 1 file changed +44
-0
lines changed Original file line number Diff line number Diff line change
1
+ # Template Method Pattern
2
+ Iterator is a behavioral design pattern that lets you traverse elements of a collection without
3
+ exposing its underlying representation (list, stack, tree, etc.).
4
+
5
+ Tutorial: [ here] ( https://refactoring.guru/design-patterns/iterator ) .
6
+
7
+ ## Diagram:
8
+ ![ image] ( https://user-images.githubusercontent.com/8049534/183165928-7274e761-09e3-48ce-b9c1-41d552fa1f1a.png )
9
+
10
+
11
+ ### Client code:
12
+ ``` dart
13
+ void main() async {
14
+ final GitHubRepo gitHubRepo = await GitHubLoader.get(
15
+ userName: 'RefactoringGuru',
16
+ repoName: 'design-patterns-dart',
17
+ );
18
+
19
+ print(
20
+ 'Iterate last 10 commits.'
21
+ '\n----------------------------',
22
+ );
23
+
24
+ for (Commit commit in gitHubRepo.commitIterator()) {
25
+ print(commit.message);
26
+ }
27
+ }
28
+ ```
29
+
30
+ ### Output:
31
+ ```
32
+ Iterate last 10 commits.
33
+ ----------------------------
34
+ Merge pull request #74 from ilopX/fix-conceptual-command-pattern-folder-name Fix conceptual command pattern folder name
35
+ Fix conceptual command pattern folder name.
36
+ Merge pull request #73 from ilopX/add-conceptual-command-pattern Add conceptual command pattern
37
+ Bump version 0.35.0.
38
+ Add README.
39
+ Impl conceptual command pattern.
40
+ Merge pull request #72 from ilopX/add-singleton-pattern Add singleton pattern.
41
+ Bump version 0.34.0.
42
+ Add README.
43
+ ```
44
+
You can’t perform that action at this time.
0 commit comments