JavaScript Callbacks Explained in 5 Minutes (Essential for asynchronous code!)
hey I'm here to drop off my car for an,oil change awesome it'll only take about,an hour and what number can we call you,at when we're done awesome yeah you can,call me back at,555-555-5555 now that's a callback,what's up everyone my name is James Q,Quick and I do weekly videos on web,development related topics and I do a,lot with JavaScript Concepts and in this,video I'm going to talk to you all about,JavaScript callbacks in about five,minutes,so the first thing we need to know,inside of JavaScript is functions are,first class citizens and actually a,callback is just a function that you,pass as a parameter to another function,that function will do some work and then,call that callback function back just,like we talked about with the oil change,example earlier in the video you say hey,I want you to do some work for me and,then you give them a mechanism to call,you back when they're done so that,you're not there waiting on that work to,be done the entire time,so let's dive into some code and take a,look at a couple of examples so the,first one I think that is the most,common is the set timeout function and,you've probably seen this before so,inside of set timeout you pass it a,function and then the second parameter,is some sort of DeLay So inside of your,function you may do something like log,hello all right so I've got this running,with the live server so this is actually,live reloading and you can see this,logging out to the browser so this whole,thing is the Callback function it's a,parameter that's being passed to set,timeout now we could move this to its,own uh separate variable so we could,call this log hello and still pass this,in the exact same way so we could pass,this in now and this will work the exact,same way,as long as we call this after that,function has been initialized so now,you'll see now one thing I do want to,check is if you know how the basics of,asynchronous JavaScript work so I'm,going to give you a little example here,we'll say two we'll do our console log,of 1 and we'll do a console log of three,so a little quiz for you and what order,are these things going to be logged out,in and even if we do this so we'll order,with those log out in let me know in the,comments below and if you want details,about how or why it maybe doesn't work,the way you expect let me know we can do,a video dedicated to that,so let's take another look at an example,of callback functions I'm going to,create an array with a few names in here,so James Jess Lily and I don't we don't,need ANS and arrays and uh savvy so this,is me my wife and my two dogs so you've,probably seen array functions like four,each before so these actually use,callbacks as well so with the for each,you pass it a callback function that,accepts a parameter of each individual,item that we name here as name and then,we can log out each one of these so,we'll just log out name now this is a,shorthand with es6 arrow functions if,you're not familiar with those let me,know I can do another
Let's move on to the first section of Callback Request
Learn useCallback In 8 Minutes
Learn useCallback In 8 Minutes
in this video I'm gonna talk about the,use callback hook which is a hook that,almost nobody uses correctly so I'm,gonna show you how to use it right so,you don't make those same mistakes also,if you want to learn everything you need,to know about react in depth make sure,to check out my full react course I have,linked down in the description below,let's get started now welcome back to,web dev simplified my name is Kyle and,my job is to simplify the web for you so,you can start building your dream,project sooner so if that sounds,interesting make sure you subscribe to,the channel for more videos just like,this one now to get started I have some,really basic react code set up that,allows us to toggle the theme on the,right from dark to light and also we can,change this number input and it's going,to change the list of numbers that are,displayed down here and I want to go,over this code really quickly just so,you can understand what's working and,why we need to use the use callback hook,to fix some problems with this code so,the very first component I have is this,basic app component and inside of here I,have state setup for both the number,input as this number input over here as,well as my dark slash light theme input,and this just gets toggled when we click,on this button then I have a single,function called get items you can kind,of imagine that this is a function that,calls out to some API somewhere and then,returns to us some results but since I,don't want to create an entire API for,this all this does is return to us three,numbers it's going to be the same number,as what's in our input one number larger,than that and then one number larger,than that one even so it's going to give,us a sequence of three numbers in a row,then we have our theme down here this,just allows us to change from dark to,light and then finally we're rendering,this all out where we have a div that,contains our theme and then we have the,input that allows us to change our,number by just coming in here and,changing this number from whatever we,want it to be a button that allows us to,toggle our theme and then the real,important code here is this list,component which takes in this function,called get items and displays out these,items so if we go to this list component,you can see this is very straightforward,we have some state for our actual items,we have a use effect and this use effect,gets called every time this and get,items function change,so every single time that we update our,get items function it recalls our use,effect to get our new items that's how,we're able to here get this new list of,items every single change we change our,number input we're also just logging out,here that we're updating their items if,we come over and we in just inspect with,our inspection tool here go to the,console and if we change our number we,should see here we get printed out,updating items so if we change it you,can see it's printing out updating items,that's exactly what we would exp
After seeing the first section, I believe you have a general understanding of Callback Request
Continue the next second section about Callback Request
Callback Hell | Ep 01 Season 02 - Namaste JavaScript
Callback Hell | Ep 01 Season 02 - Namaste JavaScript
ho ho ho i am back again to teach you,here on my channel and i am super,excited right now let's just begin this,is the first episode of this series and,we will keep it very simple and sweet,we will just cover two topics in this,episode,first one is the good part of callbacks,and the second topic is the bad part of,callbacks in the good parts we will see,that how callbacks are super important,while writing asynchronous code in,javascript,and in the bad parts we will see that,using callbacks can let us face a lot of,issues there are two major issues we,will cover both of them the first one is,call back hell and the second one is,inversion of control,yes these two issues are really very,important and you know if you understand,these two issues very well then,understanding promises in the upcoming,episodes will become very simple for you,so please i request your attention and,just keep watching this episode of,namaste javascript season 2,javascript is a synchronous single,threaded language and it can just do one,thing at a time remember it has just one,call stack and it can execute just one,thing at a time and whatever code you,give it to javascript will be quickly,executed by the javascript engine it,does not wait for anything so suppose if,we have this code over here so this code,will be quickly executed by javascript,engine and it will just quickly print on,the console these three statements let,us see that if i save here see namaste,javascript and season 2 so it just,quickly prints it and remember time tied,and javascript waits for none,but what if we really need to wait for,something suppose if in this line number,five suppose if we had to execute this,console.log javascript after five,seconds,how would we do that,so now here comes the hero of our,episode which is the callbacks so yes,what we will do is suppose if we have to,execute this line number five,after five seconds we will just wrap it,inside a callback function,let's create a function,and what we will do we will just wrap,this code inside a callback function and,we will pass it to the,set timeout isn't it so let's just,quickly do that,so now we have this callback function,inside the set timeout and we will also,pass five five thousand milliseconds in,it now listen to me very carefully we,gave this callback function to set,timeout now it is the job of set timeout,to execute this callback function after,five seconds so using callback is a,powerful way to do asynchronous thing in,javascript right so we can take a code,piece of code inside a function and we,can just pass it as a callback which can,be executed later point of time right,and our job is done so that's how,callback plays a very important role in,writing asynchronous code in javascript,so this was a very easy example let us,take one more interesting example and,you will love it so suppose we are,building our e-commerce website and you,know ecommerce website can't exist,without a cart isn't it so let's create,a cart and this is an
After seeing the second section, I believe you have a general understanding of Callback Request
Continue the next third section about Callback Request
Receive data via WordPress REST API Endpoint from API Callback URL or Webhooks
Receive data via WordPress REST API Endpoint from API Callback URL or Webhooks
Welcome back to the channel. Today I'm
going to show you something that's a,little bit different.
In most cases when you're working with,APIs there's something that's called a
callback function, WordPress has not had,a very very clear way or we've not
thought about it,in the traditional way of how to use
things like webhooks, so you had,different plugins to come
in but I've come to a place where I've,realized you know what you can actually
just use the rest API,to handle your callbacks and do a number
of things just inside WordPress itself,,so that's the beauty of it. So
here what we are looking at is, I'm,looking at the rest API
on my particular domain, so I have my,domain and I've gone to
the /wp-json and that's where,all our namespaces, that's where all our
endpoints are registered.,If you want to know more about the rest
API,,get more descriptions about it, see how
to do different things with it,,you can see the videos that I've linked
in the descriptions below.,We can see here that we have a namespace,
and we have a number of namespaces, this,wc version 1, 2 and 3 what you see is
from WooCommerce,,and then we have the wp version 2 which
of course is from WordPress itself.,So just like WooCommerce, we are able to
create our own namespaces,and do a number of things. Remember the
rest API can,get information as a method and can post
information,as a method as well. So what we're going
to do,with our rest API this time is we're
going to,post content from another website into
our own website, and we shall store that,into custom post types
and see how we can use that information,for other things.
For example the callback we've talked,about, we can use the callback like
in this instance we are going to record,payments that have been done, were they
successful?,were they done nicely? so we're going to
get that information,from somewhere else and then just post
them and save them in a custom post type,and we can use them
to do anything else in that regard. So,let's jump into the code. we're going to go
inside my site,on the manager, we're going to create a new folder,in our plugins section and we shall call
this,techiepress,callback url
functions, and,of course after creating the folder
we're going to create a new file inside,it. So
create the folder first, go inside the,function
and then we're going to create a new,file that we shall
give the same name and just add a php,extension to
it. So once we're done with that we're,going to start
editing it to add our code.,So the first thing we'll do is of course
open up our php,tags in the file, and we're
going to use an,action hook and this is for the rest API.
So the action that the action hook that,we're going to use is called rest api
init. So when the rest api is,initialized basically
what we need to do is get this,function or method in
inside to work. So we shall call it,techiepress
add callback url,endpoint. So that's what we're going to
use,as our function. And we'll copy this
and then come to funct
After seeing the third section, I believe you have a general understanding of Callback Request
Continue the next fourth section about Callback Request
okay then so far we're making this,request and then we're reacting when we,get some kind of data back or if there's,an,error now it would be nice if we could,wrap up all of this code inside a,function,called get to do's for example so that,we could call this function whenever we,want to run this code and make a request,that makes it more reusable so let's do,that first of all come to the top,and create a new constant we'll call,this get to do's that's the function,name,and set it equal to a new arrow function,like so,now inside this function that's where we,want to do all of this request of,so cut that and paste it inside here,just scoot this in a little bit all,right then so now we have,all of this request stored inside a,function and if i want to run this code,now all i have to do is come down here,and say get,to do's like so so if i save this,then everything's still going to work,the same way but the good thing is now,we're making this more reusable so i,could call this,multiple times if i wanted to now i,don't want to at the minute but the,option is there if i did,now at the minute every time we call,this to-do's function if i did call this,multiple times all we're doing,each time is just logging the response,to the console now,it would be nice if i could instead pass,in a callback function,to get to do's which we then fire over,here so we could specify,how we want to react in that callback,function then every time we call get to,do's,we could specify a different kind of,callback function to do something,different each time,if we wanted to instead of just always,doing this,inside the function so that's what i'm,going to show you how to do,the first thing we're going to do is,specify a callback function,in here as an argument to get to do's so,that will be just an empty arrow,function,at the minute now obviously since we're,passing this through as an argument we,take it inside the function as a,parameter,i'm just going to call this callback but,you can call it what you want,now when we have either some kind of,successful response,or a bad response we can instead of,logging this to the console,just called the callback so i'm just,going to say over here instead of this,like so and i'm going to do exactly the,same thing down here,callback now whenever it reaches ready,state 4 this request,and we get a status of 200 we call the,callback or even if we don't get a,status of 200 and we just reached ready,state 4,we still do that callback so this,function right here is going to fire,because we're invoking it,over here and we pass it in up here so,let's just test this i'm going to,console.log and i'm going to say,callback fired so save this and,refresh we can see now callback is fired,now the problem is even if we have an,error over here and save,we still just get callback fired we see,the error but it's still firing this and,we're getting the same,kind of action even though we've got an,error,and that's because all we're doing in,both cases over here,
After seeing the fourth section, I believe you have a general understanding of Callback Request
Continue the next fifth section about Callback Request
Asynchronous JavaScript #3 - Callback Functions
Asynchronous JavaScript #3 - Callback Functions
co-signing guys welcome to your third,asynchronous JavaScript tutorial and in,this video we're going to dive right,into callback functions Wow,all right there so callbacks are pretty,abundant in JavaScript and chances are,you've probably been using them already,in your code but just to go through the,basics again what I'm going to do is a,simple example so I'll create a variable,and I'm going to call this fruits and,this is just going to be set equal to an,array of fruits so we'll say banana,apple maybe and then pear okay so now,what I want to do is use a full reach,method to cycle through each one of,these so I'll say fruits dots for each,and then right in here what we're going,to do is pass this a function and that,there my friend is a callback function,so we have an array of fruits which for,each cycles through and as a parameter,for this for each method we pass in this,callback function and that callback,function can do something with whatever,data is passed to it in this case is,passed the value of whichever array,pocket we're up to in the for each cycle,so we'll just put in an owl and we'll,say console.log if I can spell it,without right so now we should see those,values output there to the console,banana apple and pet so in a nutshell a,callback is just a function which is,provided as a parameter to our other,methods such as for each and it is,invoked at a certain point in time now,this callback is declared in line which,basically means we've written all of the,code for this function inside these,parentheses right here as a parameter,but they don't have to be like that what,we could do instead is get rid of that,we can declare our function first of all,like this and give it a name we'll say,callback and then right in here we can,just say call that like so and this will,do exactly the same thing so it still,logs those out to the console so this is,asynchronous callback meaning it happens,right away before the function returns,and I can just demonstrate that by the,login something right here to the,console I'll say console dot log do it,and then press save and now we get done,after all this happens so this callback,function is called synchronously okay it,doesn't call it at a later point in time,which would be asynchronous it calls it,straight away does all that stuff first,and then it moves on down the thread to,the next thing which is this console dot,log message done okay so this is a,synchronous callback but we want to take,a look at asynchronous JavaScript and,what happens with callbacks then and,remember the byline of asynchronous,JavaScript is something which can start,now and then finish up later so if we,take a look at an asynchronous example,let me just get rid of all this where we,go out and retrieve some data so I'll,say jQuery don't get and this is the,method we used in the last tutorial,where we go out and grab some data using,jQuery get method going to pass in the,path to the data I want which is data,forward slash tweeks dot
After seeing the fifth section, I believe you have a general understanding of Callback Request
Continue the next sixth section about Callback Request
Callback Request Welcome Video & Tutorial - Shopify Sales App
Callback Request Welcome Video & Tutorial - Shopify Sales App
hi my name is Ahmed and I am one of the,cofounders of callback request so first,of all thank you for installing the app,then you forgive me cuss a try,you've probably installed the app so far,because you understand the importance of,phone sales so I'm not gonna go too much,into like into that category or you,already understand it I will talk a,little bit about why we built the app,and and spent a lot of time focusing on,how to use the app and how to get the,most out of it to maximize your phone,sales so that's what this video is all,about it's a tutorial it's a welcome,video if there are any questions that,you have that I haven't answered in this,video I will have shortcuts in the,YouTube in the YouTube video description,comment description that will take you,fast for you to certain components of,the video so if if any of my of your,questions aren't answered there feel,free to send us a message our contact,information is you'll be able to see on,this page so let's further adieu let's,get started now if you're seeing this,video you're probably on our overview,page in the call back section of your,Shopify apps panel now if you're seeing,a different page don't be alarmed we do,change up our overview page every now,and then if you're seeing it and maybe,that we've updated that we actually have,an update coming very soon and you'll,get resources on this page so again tips,and take the tips and tricks' links out,to our blogs obviously this video as,well as certain key actions that you can,take but enough about that let's,actually get started with the meat and,potatoes of the app why let's start with,why we built the app so we built it,specifically for stores that value their,phone sales channel there's a there's a,lot of apps out there to increase sales,obviously you're selling online there's,all these other marketing tools on these,other ways to generate leads which are,great but the phone sales the phone,number your,your businesses phone number is actually,one of the most underutilized sales,chatter it actually is a sales channel,you can make sales or the phone just,like you can make sales over Instagram,you can make sales over facebook,Messenger you can make sales obviously,on your website or in person,the phone call is another great way to,make sales that a lot of people ignore,and so really our app is about,kick-starting that catalyzing that that,that focus for merchants like you de to,go back to that phone phone sales,channel the reason it's so powerful is,because you can create a two-way voice,conversation with your customer it's the,next best thing to a real life,interaction over chat is fine but it's,text and there's a lot of asynchronous,sitting users a lot of lag someone might,not be looking you may not be looking,your customers waiting but the phone,conversation is direct its focused it's,one-on-one and when you're having a,conversation with the customer over the,phone their attention is with you right,you're you have this opportunity to,cr
After seeing the sixth section, I believe you have a general understanding of Callback Request
Continue the next seventh section about Callback Request
How do I create a callback URL?
How do I create a callback URL?
our goal is your satisfaction let us,show you the way,how do i create a callback url,to be able to set up a callback url your,website must use the https protocol,first log in to your facebook developers,account and open your application from,the sidebar menu select add product and,then webhooks,from the drop down menu select,application and then click on the,subscribe to this topic button,what is a callback url in api,callback urls are the urls that auth0,invokes after the authentication process,auth0 redirects back to this url and,appends additional parameters to it,including an access code which will be,exchanged for an id underscore token,access underscore token and refresh,underscore token,if omitted authentication will not be,successful,what is facebook callback url,the callback url is the url that will be,contacted once the user has accepted or,rejected the oauth request,this is set as a parameter of your oauth,request,so you set the url in your own program,not somewhere in facebook,what is callback in api,a callback api is defined by the service,calling the api,also referred to as a web hook or,reverse api eg when a callback api is,called the responder must handle the,request and provide a response that,conforms to what the caller expects,how do i secure a callback url,each request to the callback url must be,accompanied with jwt based token which,we need to validate to make sure,requester is allowed to send us result,data,tokens limited by path and resource,underscore id user identifier path,allowed api endpoint or path,res underscore it allowed resource,identifier,how does a callback work,a callback function is a function passed,into another function as an argument,which is then invoked inside the outer,function to complete some kind of,routine or action,a good example is the callback functions,executed in site a then block chained,onto the end of a promise after that,promise fulfills or rejects,what is auth 0 callback url,callback urls are the urls that auth0,invokes after the authentication process,auth0 redirects back to this url and,appends additional parameters to it,including an access code which will be,exchanged for an it underscore token,access underscore token and refresh,underscore token,this will enable auth xero to recognize,these urls as valid,where is the twitter callback url,as part of our continued effort to,ensure safety and security on the,twitter developer platform any developer,using sign in with twitter must,explicitly declare their callback urls,in their twitter app settings which can,be accessed in the dashboard when logged,into your twitter account on,developer.twitter,take our lead let's help you make your,mark
After seeing the seventh section, I believe you have a general understanding of Callback Request
Continue the next eighth section about Callback Request
CallBack Request Explained
CallBack Request Explained
okay what I want to do right now is show,you how to check your callback request,so what we've done is we've added to,your website on the third page of the,funnel when somebody goes here they want,you to call them back after they have,went through all this material what,they're going to do is they're going to,click on this and it's going to pull,this up it's going to say you know make,sure you've watched all the videos and,went through the entire website if you,haven't do not submit a callback because,we don't want people just calling you,randomly and saying hey you know what's,this all about we want them to go,through the videos of funnel if free,well explains it but they may have a few,more questions and they can fill this,out right thought there for the,information,see what they're interested in and you,know put a brief question then they'll,click Submit once they do that you know,it's going to show up in your back,office so what you're going to do is,you're just going to go to this leads,and you're just going to hover over this,don't click on anything over here just,going to hover over this you click on,that right there and it's going to pull,up all your call me a quote request okay,so you can see right here this is just a,demo account but you can see has their,phone numbers time zones that you should,call them in what they're interested in,if they have any questions right here's,their questions okay and then over here,this is the source that you want to pay,attention to because this tells you if,it's actually somebody that's already,joined and they've either paid you,through credit card or they've paid,through other options maybe they've,upgraded maybe they haven't you know,maybe they paid you maybe they have it,but they filled out a call for a fact,request through their back office which,I'll show you here in just second or the,funnel page so it kind of lets you know,where they are in the process right if,it's a funnel page that means they went,through your website but they're not,doing yet and then once you call them,back about you know something because,some questions they have before they,join all right so if it's a back,obviously that means that they've,already filled out the information to,pay their 297 they've either paid it,through their credit card or they've,chosen other options and gain access to,the back office but not the products and,services,unless you've upgraded them and then,they filled out a callback request back,here if they're on their dashboard and,they scroll down there's a callback,request right here right and if they,click on that they can also fill out,their information here and so that their,question click on submit if they do that,that's the back-office callback request,which shows right here okay,now once you've called them back and,you've done everything all you can do is,Marcus call it'll take them off of the,list and it won't show up any longer so,make sure you if you talked to somebody,Markham is called or if
After seeing the eighth section, I believe you have a general understanding of Callback Request
Continue the next ninth section about Callback Request
How to Add a Callback in Swift 5, iOS 13 | Xcode 11
How to Add a Callback in Swift 5, iOS 13 | Xcode 11
hey what is going on everyone welcome,back to the channel,my name is shevam and today we are going,to talk about callbacks and swift,uh callbacks are very essential because,you might need to send your data from,your current view controller to your,previous view controller,there are many ways to uh to set a,callback or,send data from your current to previous,view controller but today we are going,to talk about,of the callbacks so without any further,ado let's get started,so i'm just going to create a new,project for it,let's just name it call back,language would be swift we won't be,using code data or test,this user integrate interface would be,so report,all right,so here we have our project let's go to,the main dot square board,so we would we would be creating a very,basic app,we would be creating two view,controllers and have a communication,between both of them,so this is our main view controller,let me just add a label to it,all right let's just pin it to the,center,okay let's just name it,let me create a button just,below it,let's put the title of the button to,change,it all right let's just create our,second view control,so in second view controller we would be,adding adding a,date date picker component and we would,be changing date and that date should be,reflected,to that whenever we select the date that,it should be,you should reflect here so,let's just add the they take the cup,all right let's just bring it to center,and add some constraints to it,all right let's just create a,view view controller for it,let's just let's just name my,second view control,okay,so here we have let's just name it,new controller okay let's just,pin this one,also create a action for it whenever,date changes,or the section would be called like,value changed,so did,changed all right,let's just get this date into a,string format for that we would be,needing a date formatter,so indeed formatter we need to give the,format of the date that we that we want,to receive,so what i'm going to do is give it a,format,let's just say,and here okay,and let's just for now print the date,take formatter dot string from date,and date of so for date we will be,getting in,sender dot date okay,so now let's just uh connect this view,controller to,this so whenever we click on date change,date this view controller shift,show all right,so currently it is in the model form,let's just change it to,the full screen so it should show like,this,or it should cover full screen,and so let's just also add the,navigation view controller so that when,we are on this view controller,uh there should be a back button to go,back to this view controller,so that navigation view controller,all right as you can see so now let's,just go to our main view controller,add this date component to it,will be empty it's a label,and for change date i don't think we,would be,needing anything for anything attached,to this,uh let's just name this segway to,detail okay,so if segway dot identify equals to,detail then this
Congratulation! You bave finally finished reading Callback Request and believe you bave enougb understending Callback Request
Come on and read the rest of the article!
I am a shopify merchant, I am opening several shopify
stores. I use ppspy to find Shopify stores and track competitor stores. PPSPY really helped me a lot, I also
subscribe to PPSPY's service, I hope more people can like
PPSPY! — Ecomvy