async-await

Getting 'Uncaught' after catching error in firebase.auth() with async

放肆的年华 提交于 2020-03-19 05:16:34
问题 async login({ commit }, { email, password }) { let result try { result = await firebase.auth().signInWithEmailAndPassword(email, password) commit('setUser', result.user) } catch (err) { commit('setError', err) } } This is an action in Vuex. When this runs, I expect the commit('seteError', err) to be a valid error handler for the error returned from catch (err) . Instead, I get an 'Uncaught' exception and execution stops. Would appreciate any insights from anyone who managed to use async with

Getting 'Uncaught' after catching error in firebase.auth() with async

天大地大妈咪最大 提交于 2020-03-19 05:14:11
问题 async login({ commit }, { email, password }) { let result try { result = await firebase.auth().signInWithEmailAndPassword(email, password) commit('setUser', result.user) } catch (err) { commit('setError', err) } } This is an action in Vuex. When this runs, I expect the commit('seteError', err) to be a valid error handler for the error returned from catch (err) . Instead, I get an 'Uncaught' exception and execution stops. Would appreciate any insights from anyone who managed to use async with

how to make python awaitable object

 ̄綄美尐妖づ 提交于 2020-03-18 03:51:57
问题 In python 3.5.1 one can make use of await/async, however, to use it (as I undestand), you need to have awaitable object . An awaitable object is an object that defines __await__() method returning an iterator. More info here. But I can not google out any example of having this, since most examples have some sort of asyncio.sleep(x) to mimic awaitable object. My ultimate goal is to make simple websocket serial server, however, I can't pass this first step. This is my (non working code). import

await await vs Unwrap()

微笑、不失礼 提交于 2020-03-17 07:59:40
问题 Given a method such as public async Task<Task> ActionAsync() { ... } What is the difference between await await ActionAsync(); and await ActionAsync().Unwrap(); if any. 回答1: Unwrap() creates a new task instance that represent whole operation on each call. In contrast to await task created in such a way is differ from original inner task. See the Unwrap() docs, and consider the following code: private async static Task Foo() { Task<Task<int>> barMarker = Bar(); Task<int> awaitedMarker = await

Are there DBSet.UpdateAsync() and RemoveAsync() in .net core?

纵然是瞬间 提交于 2020-03-17 06:57:39
问题 I could not find any info on this anywhere. There are ToListAsync(), AddAsync() and more, but could not find any documentation about UpdateAsync() or RemoveAsync(). Does anyone know anything about this? 回答1: ToListAsync exists because it actually causes EF to head off to the data store to retrieve the data. This may take some time, hence why you can call it asynchronously. AddAsync however, only begins tracking an entity but won't actually send any changes to the database until you call

Creating an awaitable System.Timers.Timer

会有一股神秘感。 提交于 2020-03-17 03:33:07
问题 I had an idea about creating a timer that can be awaited, instead of raising events. I haven't thought of any practical applications yet, and may not be something terribly useful, but I would like to see if it's at least doable as an exercise. This is how it could be used: var timer = new System.Timers.Timer(); timer.Interval = 100; timer.Enabled = true; for (int i = 0; i < 10; i++) { var signalTime = await timer; Console.WriteLine($"Awaited {i}, SignalTime: {signalTime:HH:mm:ss.fff}"); } The

Creating an awaitable System.Timers.Timer

送分小仙女□ 提交于 2020-03-17 03:32:02
问题 I had an idea about creating a timer that can be awaited, instead of raising events. I haven't thought of any practical applications yet, and may not be something terribly useful, but I would like to see if it's at least doable as an exercise. This is how it could be used: var timer = new System.Timers.Timer(); timer.Interval = 100; timer.Enabled = true; for (int i = 0; i < 10; i++) { var signalTime = await timer; Console.WriteLine($"Awaited {i}, SignalTime: {signalTime:HH:mm:ss.fff}"); } The

Why do my code lines after await not get called?

点点圈 提交于 2020-03-16 09:14:45
问题 I have a problem with the following code. The firebase.login returns a Promise and I learned that, when I put "await" before, Javascript waits until the Promise delivers and then continues with the next line.I But the next line(s) seem never to be triggered. What am I doing wrong? It also does not stop at the "debugger" mark. try { const user = await firebase.login(email, password); console.log("l1: ", user); debugger; props.history.replace("/impressum"); } catch (error) { alert(error.message

Mixing async-await with fire-and-forget approach

我怕爱的太早我们不能终老 提交于 2020-03-05 04:11:51
问题 I'm writing a websocket server using .NET's HttpListener class. Essentially, I've got a HandleListener() function which wait for clients to connect and yield each client to HandleClient(WebSocket client) . So I currently have: private async void HandleListener() { try { while (listener != null && listener.IsListening) { HttpListenerContext listenerContext = await listener.GetContextAsync(); WebSocketContext webSocketContext = await listenerContext.AcceptWebSocketAsync(subProtocol: null);

Using IAsyncEnumerable with Dapper

好久不见. 提交于 2020-03-05 02:51:06
问题 We have recently migrated our ASP.NET Core API which uses Dapper to .NET Core 3.1. After the migration, we felt there was an opportunity to use the latest IAsyncEnumerable feature from C# 8 for one of our endpoints. Here is the pseudocode before the changes: public async Task<IEnumerable<Item>> GetItems(int id) { var reader = await _connection.QueryMultipleAsync(getItemsSql, param: new { Id = id }); var idFromDb = (await reader.ReadAsync<int?>().ConfigureAwait(false)).SingleOrDefault(); if