Skip to content

Commit

Permalink
Use Streams instead of Futures in a lot of places.
Browse files Browse the repository at this point in the history
  • Loading branch information
azenla committed Aug 24, 2014
1 parent 56d5e4d commit bd827ff
Show file tree
Hide file tree
Showing 12 changed files with 113 additions and 229 deletions.
2 changes: 1 addition & 1 deletion example/releases.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ void main() {
}

void loadReleases() {
github.releases(new RepositorySlug("twbs", "bootstrap")).then((releases) {
github.releases(new RepositorySlug("twbs", "bootstrap")).toList().then((releases) {
for (var release in releases) {
$releases.appendHtml("""
<div class="repo box" id="release-${release.id}">
Expand Down
2 changes: 1 addition & 1 deletion example/repos.dart
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ void loadRepos([int compare(Repository a, Repository b)]) {
compare = (a, b) => a.name.compareTo(b.name);
}

github.userRepositories(user).then((repos) {
github.userRepositories(user).toList().then((repos) {
repos.sort(compare);

for (var repo in repos) {
Expand Down
2 changes: 1 addition & 1 deletion example/stars.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ void loadStars() {

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

github.stargazersStreamed(new RepositorySlug(user, repo)).listen((stargazer) {
github.stargazers(new RepositorySlug(user, repo)).listen((stargazer) {
var h = new DivElement();
h.classes.add("box");
h.classes.add("user");
Expand Down
12 changes: 5 additions & 7 deletions example/users.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,12 @@ void main() {
}

void loadUsers() {
github.users(["kaendfinger", "samrg472", "TrainerGuy22", "logangorence"]).then((List<User> users) {
users.forEach((User user) {
var element = new DivElement();
var out = """
github.users(["kaendfinger", "samrg472", "TrainerGuy22", "logangorence"]).listen((User user) {
var element = new DivElement();
var out = """
<img width="64" height="64" src="${user.avatarUrl}">&nbsp;&nbsp;<b>${user.login}</b>
""";
element.append(new ParagraphElement()..appendHtml(out));
$users.append(element);
});
element.append(new ParagraphElement()..appendHtml(out));
$users.append(element);
});
}
3 changes: 3 additions & 0 deletions lib/common.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ import 'package:crypto/crypto.dart' show CryptoUtils;
import "package:html5lib/parser.dart" as htmlParser;
import "package:html5lib/dom.dart" as html;

import 'package:quiver/async.dart';
import 'package:quiver/streams.dart';

import 'http.dart' as http;

import 'src/common/util.dart';
Expand Down
2 changes: 1 addition & 1 deletion lib/src/common/gists.dart
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class Gist {
return gist;
}

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

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

0 comments on commit bd827ff

Please sign in to comment.