{"id":4767,"date":"2014-03-30T15:16:46","date_gmt":"2014-03-30T15:16:46","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/asynchronous-callback-in-gwt-why-final-collection-of-common-programming-errors\/"},"modified":"2014-03-30T15:16:46","modified_gmt":"2014-03-30T15:16:46","slug":"asynchronous-callback-in-gwt-why-final-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/asynchronous-callback-in-gwt-why-final-collection-of-common-programming-errors\/","title":{"rendered":"Asynchronous Callback in GWT &#8211; why final?-Collection of common programming errors"},"content":{"rendered":"<p>I am developing an application in GWT as my Bachelor&#8217;s Thesis and I am fairly new to this. I have researched asynchronous callbacks on the internet. What I want to do is this: I want to handle the login of a user and display different data if they are an admin or a plain user.<\/p>\n<p>My call looks like this:<\/p>\n<pre><code>serverCall.isAdmin(new AsyncCallback() {\n        public void onFailure(Throwable caught) {\n            \/\/display error\n        }\n\n        public void onSuccess(Boolean admin) {\n            if (!admin){\n                \/\/do something \n            }\n            else{\n                \/\/do something else\n            }\n\n        }\n    });\n<\/code><\/pre>\n<p>Now, the code examples I have seen handle the data in the \/\/do something\/\/ part directly. We discussed this with the person who is supervising me and I had the idea that I could fire an event upon success and when this event is fired load the page accordingly. Is this a good idea? Or should I stick with loading everything in the inner function? What confuses me about async callbacks is the fact that I can only use final variables inside the onSuccess function so I would rather not handle things in there &#8211; insight would be appreciated.<\/p>\n<p>Thanks!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I am developing an application in GWT as my Bachelor&#8217;s Thesis and I am fairly new to this. I have researched asynchronous callbacks on the internet. What I want to do is this: I want to handle the login of a user and display different data if they are an admin or a plain user. [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-4767","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/4767","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=4767"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/4767\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=4767"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=4767"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=4767"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}