This article mainly introduces the basic usage of the JS builder mode, and analyzes in detail the implementation method of the javascript builder mode in the form of a complete example, for more information about the basic usage of the JS builder mode, see the examples in this article. Share it with you for your reference. The specific implementation method is as follows:
Function getBeerById (id, callback) {_ request ('GET', 'URL' + id, function (res) {callback (res. responseText)}) ;}; function getBeerByIdBridge () {getBeerById (id, function (res) {alert (res. toString () ;}); // doAnothering ;}; var el = document. querySelector ('# test'); el. addEventListener ('click', getBeerByIdBrige, false );
The so-called builder mode is similar to the bridge mode. it is a common callback, which makes the idea clearer.
I hope this article will help you design javascript programs.