def onUserClick(event) { // call me maybe
event.getUser().sendGreeting();
}
async.register("user-click", onUserClick);
def onUserClick(event) {
def onUserFound(user) {
user.sendGreeting();
};
async.register("find-user", onUserFound);
}
async.register("user-click", onUserClick);
saveKingdom(function(kingdom) {
kingdom.fightBattle(function(battle) {
battle.getMessage(function(message) {
message.getRider(function(rider) {
rider.getHorse(function(horse) {
horse.getShoe(function(shoe) {
shoe.getNail(function(nail) {
saveTheKingdom();
});
});
});
});
});
});
}); => // RuntimeException: NailNotFound
/\
___ / \ ___ / \ __ / \ __ / / \ / \ _ / <()> \ _ / \ / \_/ \_/ \_/________\_/ \_/ \_/ __________________/__I___I___\________________ /_I___I___I__\ /I___I___I___I_\ /___I___I___I___I\ /__I___I___I___I___\ /_I___I___I___I___I__\ /I___I___I___I___I___I_\ /___I___I___I___I___I___I\ /__I___I___I___I___I___I___\ /_I___I___I___I___I___I___I__\
something might happen
(the promise was fulfilled)
loginRequest.then(function(user) {
return user.authenticate(); // => AuthenticatedUser
}).then(function(authedUser) {
authedUser.useSystem();
});
keys = rx.observable("keypress");
enter = keys.filter(function(key) {
return key == ENTER_CODE;
});
enter.subscribe(doWork);
getStringsFromNetwork()
.skip(10) // who cares about the first ten messages .take(5) // i only want five messages .map({ s -> return(s + "_transformed"); }) .subscribe({ it -> println("onNext => " + it); });