{"action":"created","issue":{"url":"https://api.github.com/repos/aspnet/Blazor/issues/163","repository_url":"https://api.github.com/repos/aspnet/Blazor","labels_url":"https://api.github.com/repos/aspnet/Blazor/issues/163/labels{/name}","comments_url":"https://api.github.com/repos/aspnet/Blazor/issues/163/comments","events_url":"https://api.github.com/repos/aspnet/Blazor/issues/163/events","html_url":"https://github.com/aspnet/Blazor/issues/163","id":299953185,"number":163,"title":"Calling an async function via onclick.","user":{"login":"RyoukoKonpaku","id":36291250,"avatar_url":"https://avatars1.githubusercontent.com/u/36291250?v=4","gravatar_id":"","url":"https://api.github.com/users/RyoukoKonpaku","html_url":"https://github.com/RyoukoKonpaku","followers_url":"https://api.github.com/users/RyoukoKonpaku/followers","following_url":"https://api.github.com/users/RyoukoKonpaku/following{/other_user}","gists_url":"https://api.github.com/users/RyoukoKonpaku/gists{/gist_id}","starred_url":"https://api.github.com/users/RyoukoKonpaku/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RyoukoKonpaku/subscriptions","organizations_url":"https://api.github.com/users/RyoukoKonpaku/orgs","repos_url":"https://api.github.com/users/RyoukoKonpaku/repos","events_url":"https://api.github.com/users/RyoukoKonpaku/events{/privacy}","received_events_url":"https://api.github.com/users/RyoukoKonpaku/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2018-02-24T16:32:08Z","updated_at":"2018-02-25T10:42:14Z","closed_at":"2018-02-25T10:40:17Z","author_association":"NONE","body":"I have been messing around with the HttpClient so far and wanted to create an async call to an Endpoint via a button click.\r\nSomething like this.\r\n```\r\n// Something that should update once the async call is done\r\nif(!isDone) { <text>Processing</text> }\r\nelse { <text>Done: @responseText</text> }\r\n// Button\r\n<button type=\"button\" @onclick(GetClick)>Get Some Data</button>\r\n// Function\r\n    async Task GetClick()\r\n    {\r\n        responseText = await Http.GetStringAsync(\"/\");\r\n        isDone = true;\r\n     }\r\n```\r\n\r\nThe problem is that onClick directive doesn't allow a function that returns anything it seems and only accepts void. By changing the return type to void from Task, it works but since it's an async task the Page doesn't update it's view when the async task is done and isDone is set to true since I think the component isn't notified.\r\n\r\nThe workaround I did is to put StateHasChanged() as the last call on the async void function to manually notify the component to render.\r\nMaybe i'm doing something wrong and there's already a way for this though. Just to clarify I guess.\r\n"},"comment":{"url":"https://api.github.com/repos/aspnet/Blazor/issues/comments/368299263","html_url":"https://github.com/aspnet/Blazor/issues/163#issuecomment-368299263","issue_url":"https://api.github.com/repos/aspnet/Blazor/issues/163","id":368299263,"user":{"login":"RyoukoKonpaku","id":36291250,"avatar_url":"https://avatars1.githubusercontent.com/u/36291250?v=4","gravatar_id":"","url":"https://api.github.com/users/RyoukoKonpaku","html_url":"https://github.com/RyoukoKonpaku","followers_url":"https://api.github.com/users/RyoukoKonpaku/followers","following_url":"https://api.github.com/users/RyoukoKonpaku/following{/other_user}","gists_url":"https://api.github.com/users/RyoukoKonpaku/gists{/gist_id}","starred_url":"https://api.github.com/users/RyoukoKonpaku/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RyoukoKonpaku/subscriptions","organizations_url":"https://api.github.com/users/RyoukoKonpaku/orgs","repos_url":"https://api.github.com/users/RyoukoKonpaku/repos","events_url":"https://api.github.com/users/RyoukoKonpaku/events{/privacy}","received_events_url":"https://api.github.com/users/RyoukoKonpaku/received_events","type":"User","site_admin":false},"created_at":"2018-02-25T10:42:14Z","updated_at":"2018-02-25T10:42:14Z","author_association":"NONE","body":"Ah good to know, thanks for the clarification."}}
{"actor":{"display_login":"RyoukoKonpaku"}}