我不确定什么时候用什么。
你得到nuxt build两个目录(client&server)这意味着你实际上正在部署node.js服务器(即express,对吧?)
与nuxt generate你一起得到.html
看来这两种方式都可以实现 nuxt 所追求的良好 SEO。对我来说,nuxt generate选项似乎更简洁,因为它不涉及服务器。
我在这里缺少什么?为什么我应该使用nuxt build并混淆服务器代码?
我看到 @python 3.9+ 添加了 asyncio.to_thread() 方法,它的描述说它在单独的线程上运行阻塞代码以立即运行。见下面的例子:
def blocking_io():
print(f"start blocking_io at {time.strftime('%X')}")
# Note that time.sleep() can be replaced with any blocking
# IO-bound operation, such as file operations.
time.sleep(1)
print(f"blocking_io complete at {time.strftime('%X')}")
async def main():
print(f"started main at {time.strftime('%X')}")
await asyncio.gather(
asyncio.to_thread(blocking_io),
asyncio.sleep(1))
print(f"finished main at {time.strftime('%X')}")
asyncio.run(main())
# Expected output:
#
# started main at 19:50:53
# start blocking_io at 19:50:53
# blocking_io complete at 19:50:54
# finished main at 19:50:54
Run Code Online (Sandbox Code Playgroud)
通过解释,它似乎使用线程机制而不是上下文切换或协程。这是否意味着它实际上并不是异步的?它与concurrent.futures.ThreadPoolExecutor中的传统多线程相同吗?那么这样使用线程有什么好处呢?
我正在使用 expo + supabase 做反应本机项目。
来自其快速入门文档,( https://supabase.com/docs/guides/with-expo#launch )
import 'react-native-url-polyfill/auto'
import { useState, useEffect } from 'react'
import { supabase } from './lib/supabase'
import Auth from './components/Auth'
import Account from './components/Account'
import { View } from 'react-native'
import { Session } from '@supabase/supabase-js'
export default function App() {
const [session, setSession] = (useState < Session) | (null > null) // <-- what is this?
useEffect(() => {
setSession(supabase.auth.session())
supabase.auth.onAuthStateChange((_event, session) => {
setSession(session)
})
}, [])
return (
<View>
{session …Run Code Online (Sandbox Code Playgroud)