This file contains hidden or 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
expect(App.reqres).toHaveBeenCalledWith("favouriteLanguages", "Victor"); |
This file contains hidden or 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
library streams; | |
import 'dart:html'; | |
import 'dart:async'; | |
import 'dart:uri'; | |
import 'dart:json' as JSON; | |
import 'package:js/js.dart' as js; | |
main() { | |
var inputs = |
This file contains hidden or 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
Wikipedia Search <input id="query"/> | |
<h1>Result</h1> | |
<ul id="items"></ul> |
This file contains hidden or 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
var inputs = | |
$("#query"). | |
keyupAsObservable(). | |
select(function(event){return event.target.value;}). | |
where(function(text){return text.length > 2;}). | |
throttle(500). | |
distinctUntilChanged(); | |
inputs. | |
select(queryWikipedia). |
This file contains hidden or 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
function queryWikipedia(term) { | |
var url = "http://en.wikipedia.org/w/api.php"; | |
var data = {action: 'opensearch', search: encodeURI(term)}; | |
return $.getAsObservable(url, data, 'jsonp'); | |
} | |
function updateResults(items){ | |
var ul = $("#items"); | |
ul.html(_.map(items, function(item){ | |
return "<li>" + item + "</li>"; |
This file contains hidden or 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
query("#query"). | |
onKeyUp |
This file contains hidden or 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
query("#query"). | |
onKeyUp. | |
map((event) => event.target.value) |
This file contains hidden or 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
query("#query"). | |
onKeyUp. | |
map((event) => event.target.value). | |
where((text) => text.length > 2) |
This file contains hidden or 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
class Throttle<T> extends StreamEventTransformer<T,T> { | |
final duration; | |
Timer lastTimer; | |
Throttle(millis) :duration = new Duration(milliseconds : millis); | |
void handleData(T event, EventSink sink) { | |
if (lastTimer != null) { | |
lastTimer.cancel(); | |
} | |
lastTimer = new Timer(duration, () => sink.add(event)); |
This file contains hidden or 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
var inputs = | |
query("#query"). | |
onKeyUp. | |
map((event) => event.target.value). | |
where((text) => text.length > 2). | |
transform(new Throttle(500)). | |
distinct(); |