Skip to content

Instantly share code, notes, and snippets.

@hpyhacking
Created December 1, 2022 16:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hpyhacking/5678d1ee88f238d5975ddd4573c6579f to your computer and use it in GitHub Desktop.
Save hpyhacking/5678d1ee88f238d5975ddd4573c6579f to your computer and use it in GitHub Desktop.
callback
class Geocoding {
search(query, callback) {
// dosomething and take data
// data = 1
//
// let data = 1
//return data
//
jQuery.ajax('a.json', function(data) {
callback(data)
})
//callback(data)
}
}
// search_ui.js
//
let callback = function(data) {
// do something
$('text').text(data.lot)
}
let callback1 = function(data) {
// do something
$('text-1').text(data.lot)
}
let a = new Geocoding()
a.search(query, callback)
a.search(query, callback1)
function a(callback) {
console.log('a')
callback()
}
function b(callback) {
console.log('b')
callback()
}
function c(callback) {
console.log('c')
callback()
}
c(function() { a(b) })
//let x = function() {
//a(b)
//}
//c(x)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment