Patrice Chalin 3aa533f61b chore(dart): pipes example rolled back to beta.15
The pipes example stopped working in beta.16; roll it back to the
last known working version. 

See earlier commit for code changes necessary in support of beta.16:
https://github.com/angular/angular.io/commit/0557c728d75e519bc6846b37492
414dff540c6ee
2016-04-30 15:06:00 +01:00

24 lines
562 B
Dart

// #docregion
import 'dart:html';
import 'dart:async';
import 'dart:convert';
import 'package:angular2/angular2.dart';
// #docregion pipe-metadata
@Pipe(name: 'fetch', pure: false)
// #enddocregion pipe-metadata
class FetchJsonPipe extends PipeTransform {
dynamic _fetchedValue;
Future<dynamic> _fetchPromise;
transform(dynamic url, [List<dynamic> args]) {
if (_fetchPromise == null) {
_fetchPromise = new Future(() async {
_fetchedValue = JSON.decode(await HttpRequest.getString(url));
});
}
return _fetchedValue;
}
}