J.D Nicholls
Founding Full-Stack Web3 Engineer at @baxusco | Digital nomad 🎒 | Mentor 👨🏫 | Speaker 🗣️ | Developer 👨💻 | Creator of @proyecto26 #opensource #developer
Callbacks VS Promises
are computer-program components that generalize subroutines for non-preemptive multitasking, by allowing multiple entry points for suspending and resuming execution at certain locations.
is a software design pattern that restricts the instantiation of a class to one object. This is useful when exactly one object is needed to coordinate actions across the system.
RequestHelper.GetArray<Post>(root + "/posts", (err, res) => {
if(err != null){
EditorUtility.DisplayDialog ("Error", err.Message, "Ok");
}
else{
EditorUtility.DisplayDialog ("Success", JsonHelper.ArrayToJson<Post>(res, true), "Ok");
}
RequestHelper.GetArray<Todo>(root + "/todos", (err, res) => {
if(err != null){
EditorUtility.DisplayDialog ("Error", err.Message, "Ok");
}
else{
EditorUtility.DisplayDialog ("Success", JsonHelper.ArrayToJson<Todo>(res, true), "Ok");
}
//RequestHelper.GetArray<User>(root + "/users"...
});
});
RequestHelper.GetArray<Post>(root + "/posts").Then(res => {
EditorUtility.DisplayDialog ("Success", JsonHelper.ArrayToJson<Post>(res, true), "Ok");
return RequestHelper.GetArray<Todo>(root + "/todos");
}).Then(res => {
EditorUtility.DisplayDialog ("Success", JsonHelper.ArrayToJson<Todo>(res, true), "Ok");
return RequestHelper.GetArray<User>(root + "/users");
}).Then(res => {
EditorUtility.DisplayDialog ("Success", JsonHelper.ArrayToJson<User>(res, true), "Ok");
}).Catch(err => EditorUtility.DisplayDialog ("Error", err.Message, "Ok"));
By J.D Nicholls
Founding Full-Stack Web3 Engineer at @baxusco | Digital nomad 🎒 | Mentor 👨🏫 | Speaker 🗣️ | Developer 👨💻 | Creator of @proyecto26 #opensource #developer