function fetchData(callback) {
// get me data
callback(data);
}
fetchData(function(data) {
// do something with the data
});
<input type="button" id="submitButton" value="Submit" />
jQuery('#submitButton').click(function() {
// do some funky stuff
});
interface IEnumerable<T> {
IEnumerator<T> GetEnumerator();
}
interface IEnumerator<T> {
bool MoveNext();
T GetCurrent();
}
function fetchData() {
var products = getProducts();
for(var index = 0; index < products.size(); index++) {
// populate data
// data 1
// data 2
// data 3
// stuck
}
}
interface IObservable<T> {
void Subscribe(IObserver<T> observer);
}
interface IObserver<T> {
void OnNext(T value);
void OnError();
void OnCompleted();
}
> X = 10;
10
> Y = 10;
10
> A = X + Y;
20
> X = 20;
> A
20
X = 22
Y = 33
A = X+Y =
function setA(){ // A=X+Y as integers
var A = parseInt($('#X').text()) + parseInt($('#Y').text());
$('#A').text( A );
}
setA();
$('#X,#Y').css('cursor','pointer').click(function(){
// by reaction to a click: updates A and X or Y
var obj = $(this);
obj.text(parseInt(obj.text())+1);
setA();
});