Skip to content

Commit bd827ff

Browse files
committed
Use Streams instead of Futures in a lot of places.
1 parent 56d5e4d commit bd827ff

File tree

12 files changed

+113
-229
lines changed

12 files changed

+113
-229
lines changed

example/releases.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ void main() {
1717
}
1818

1919
void loadReleases() {
20-
github.releases(new RepositorySlug("twbs", "bootstrap")).then((releases) {
20+
github.releases(new RepositorySlug("twbs", "bootstrap")).toList().then((releases) {
2121
for (var release in releases) {
2222
$releases.appendHtml("""
2323
<div class="repo box" id="release-${release.id}">

example/repos.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ void loadRepos([int compare(Repository a, Repository b)]) {
9797
compare = (a, b) => a.name.compareTo(b.name);
9898
}
9999

100-
github.userRepositories(user).then((repos) {
100+
github.userRepositories(user).toList().then((repos) {
101101
repos.sort(compare);
102102

103103
for (var repo in repos) {

example/stars.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ void loadStars() {
3939

4040
querySelector("#title").appendText(" for ${user}/${repo}");
4141

42-
github.stargazersStreamed(new RepositorySlug(user, repo)).listen((stargazer) {
42+
github.stargazers(new RepositorySlug(user, repo)).listen((stargazer) {
4343
var h = new DivElement();
4444
h.classes.add("box");
4545
h.classes.add("user");

example/users.dart

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,12 @@ void main() {
1717
}
1818

1919
void loadUsers() {
20-
github.users(["kaendfinger", "samrg472", "TrainerGuy22", "logangorence"]).then((List<User> users) {
21-
users.forEach((User user) {
22-
var element = new DivElement();
23-
var out = """
20+
github.users(["kaendfinger", "samrg472", "TrainerGuy22", "logangorence"]).listen((User user) {
21+
var element = new DivElement();
22+
var out = """
2423
<img width="64" height="64" src="${user.avatarUrl}">&nbsp;&nbsp;<b>${user.login}</b>
2524
""";
26-
element.append(new ParagraphElement()..appendHtml(out));
27-
$users.append(element);
28-
});
25+
element.append(new ParagraphElement()..appendHtml(out));
26+
$users.append(element);
2927
});
3028
}

lib/common.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ import 'package:crypto/crypto.dart' show CryptoUtils;
77
import "package:html5lib/parser.dart" as htmlParser;
88
import "package:html5lib/dom.dart" as html;
99

10+
import 'package:quiver/async.dart';
11+
import 'package:quiver/streams.dart';
12+
1013
import 'http.dart' as http;
1114

1215
import 'src/common/util.dart';

lib/src/common/gists.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ class Gist {
6262
return gist;
6363
}
6464

65-
Future<List<GistComment>> comments() => github.gistComments(json['id']);
65+
Stream<GistComment> comments() => github.gistComments(json['id']);
6666

6767
Future<GistComment> comment(CreateGistComment request) {
6868
return github.postJSON("/gists/${json['id']}/comments", body: request.toJSON(), convert: GistComment.fromJSON);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy