Difference Between Async/Await and Effect.gen with tryPromise in Nuxt Context
hi, what is the difference between these two and why async version works propery but not effect ones?
async function abc() {
await tryUseNuxtApp()?.runWithContext(() => console.log('beacon in nuxt context')) // logs
await tryUseNuxtApp()?.runWithContext(() => console.log('another beacon in nuxt context')) //logs
}async function abc() {
await tryUseNuxtApp()?.runWithContext(() => console.log('beacon in nuxt context')) // logs
await tryUseNuxtApp()?.runWithContext(() => console.log('another beacon in nuxt context')) //logs
}Effect.gen(function* () {
yield * Effect.tryPromise({
try: async () => await tryUseNuxtApp()?.runWithContext(() => console.log('first in context')), // logs
catch: error => new UnknownApplicationError({ error }, `Unexpected error while executing in Nuxt context. ${(error as Error).message}`),
})
yield * Effect.tryPromise({
try: async () => await tryUseNuxtApp()?.runWithContext(() => console.log('second in context')), // doesnt log
catch: error => new UnknownApplicationError({ error }, `Unexpected error while executing in Nuxt context. ${(error as Error).message}`),
})
})Effect.gen(function* () {
yield * Effect.tryPromise({
try: async () => await tryUseNuxtApp()?.runWithContext(() => console.log('first in context')), // logs
catch: error => new UnknownApplicationError({ error }, `Unexpected error while executing in Nuxt context. ${(error as Error).message}`),
})
yield * Effect.tryPromise({
try: async () => await tryUseNuxtApp()?.runWithContext(() => console.log('second in context')), // doesnt log
catch: error => new UnknownApplicationError({ error }, `Unexpected error while executing in Nuxt context. ${(error as Error).message}`),
})
})