0.1.2 #4

Merged
Thilawyn merged 57 commits from next into master 2025-02-26 19:27:39 +01:00
4 changed files with 66 additions and 15 deletions
Showing only changes of commit e83e86f8f1 - Show all commits

View File

@@ -13,6 +13,7 @@
import { Route as rootRoute } from './routes/__root' import { Route as rootRoute } from './routes/__root'
import { Route as TimeImport } from './routes/time' import { Route as TimeImport } from './routes/time'
import { Route as TestsImport } from './routes/tests' import { Route as TestsImport } from './routes/tests'
import { Route as PromiseImport } from './routes/promise'
import { Route as CountImport } from './routes/count' import { Route as CountImport } from './routes/count'
import { Route as BlankImport } from './routes/blank' import { Route as BlankImport } from './routes/blank'
import { Route as IndexImport } from './routes/index' import { Route as IndexImport } from './routes/index'
@@ -31,6 +32,12 @@ const TestsRoute = TestsImport.update({
getParentRoute: () => rootRoute, getParentRoute: () => rootRoute,
} as any) } as any)
const PromiseRoute = PromiseImport.update({
id: '/promise',
path: '/promise',
getParentRoute: () => rootRoute,
} as any)
const CountRoute = CountImport.update({ const CountRoute = CountImport.update({
id: '/count', id: '/count',
path: '/count', path: '/count',
@@ -74,6 +81,13 @@ declare module '@tanstack/react-router' {
preLoaderRoute: typeof CountImport preLoaderRoute: typeof CountImport
parentRoute: typeof rootRoute parentRoute: typeof rootRoute
} }
'/promise': {
id: '/promise'
path: '/promise'
fullPath: '/promise'
preLoaderRoute: typeof PromiseImport
parentRoute: typeof rootRoute
}
'/tests': { '/tests': {
id: '/tests' id: '/tests'
path: '/tests' path: '/tests'
@@ -97,6 +111,7 @@ export interface FileRoutesByFullPath {
'/': typeof IndexRoute '/': typeof IndexRoute
'/blank': typeof BlankRoute '/blank': typeof BlankRoute
'/count': typeof CountRoute '/count': typeof CountRoute
'/promise': typeof PromiseRoute
'/tests': typeof TestsRoute '/tests': typeof TestsRoute
'/time': typeof TimeRoute '/time': typeof TimeRoute
} }
@@ -105,6 +120,7 @@ export interface FileRoutesByTo {
'/': typeof IndexRoute '/': typeof IndexRoute
'/blank': typeof BlankRoute '/blank': typeof BlankRoute
'/count': typeof CountRoute '/count': typeof CountRoute
'/promise': typeof PromiseRoute
'/tests': typeof TestsRoute '/tests': typeof TestsRoute
'/time': typeof TimeRoute '/time': typeof TimeRoute
} }
@@ -114,16 +130,17 @@ export interface FileRoutesById {
'/': typeof IndexRoute '/': typeof IndexRoute
'/blank': typeof BlankRoute '/blank': typeof BlankRoute
'/count': typeof CountRoute '/count': typeof CountRoute
'/promise': typeof PromiseRoute
'/tests': typeof TestsRoute '/tests': typeof TestsRoute
'/time': typeof TimeRoute '/time': typeof TimeRoute
} }
export interface FileRouteTypes { export interface FileRouteTypes {
fileRoutesByFullPath: FileRoutesByFullPath fileRoutesByFullPath: FileRoutesByFullPath
fullPaths: '/' | '/blank' | '/count' | '/tests' | '/time' fullPaths: '/' | '/blank' | '/count' | '/promise' | '/tests' | '/time'
fileRoutesByTo: FileRoutesByTo fileRoutesByTo: FileRoutesByTo
to: '/' | '/blank' | '/count' | '/tests' | '/time' to: '/' | '/blank' | '/count' | '/promise' | '/tests' | '/time'
id: '__root__' | '/' | '/blank' | '/count' | '/tests' | '/time' id: '__root__' | '/' | '/blank' | '/count' | '/promise' | '/tests' | '/time'
fileRoutesById: FileRoutesById fileRoutesById: FileRoutesById
} }
@@ -131,6 +148,7 @@ export interface RootRouteChildren {
IndexRoute: typeof IndexRoute IndexRoute: typeof IndexRoute
BlankRoute: typeof BlankRoute BlankRoute: typeof BlankRoute
CountRoute: typeof CountRoute CountRoute: typeof CountRoute
PromiseRoute: typeof PromiseRoute
TestsRoute: typeof TestsRoute TestsRoute: typeof TestsRoute
TimeRoute: typeof TimeRoute TimeRoute: typeof TimeRoute
} }
@@ -139,6 +157,7 @@ const rootRouteChildren: RootRouteChildren = {
IndexRoute: IndexRoute, IndexRoute: IndexRoute,
BlankRoute: BlankRoute, BlankRoute: BlankRoute,
CountRoute: CountRoute, CountRoute: CountRoute,
PromiseRoute: PromiseRoute,
TestsRoute: TestsRoute, TestsRoute: TestsRoute,
TimeRoute: TimeRoute, TimeRoute: TimeRoute,
} }
@@ -156,6 +175,7 @@ export const routeTree = rootRoute
"/", "/",
"/blank", "/blank",
"/count", "/count",
"/promise",
"/tests", "/tests",
"/time" "/time"
] ]
@@ -169,6 +189,9 @@ export const routeTree = rootRoute
"/count": { "/count": {
"filePath": "count.tsx" "filePath": "count.tsx"
}, },
"/promise": {
"filePath": "promise.tsx"
},
"/tests": { "/tests": {
"filePath": "tests.tsx" "filePath": "tests.tsx"
}, },

View File

@@ -19,6 +19,7 @@ function Root() {
<Link to="/time">Time</Link> <Link to="/time">Time</Link>
<Link to="/count">Count</Link> <Link to="/count">Count</Link>
<Link to="/tests">Tests</Link> <Link to="/tests">Tests</Link>
<Link to="/promise">Promise</Link>
<Link to="/blank">Blank</Link> <Link to="/blank">Blank</Link>
</Flex> </Flex>
</Container> </Container>

View File

@@ -0,0 +1,31 @@
import { R } from "@/reffuse"
import { HttpClient } from "@effect/platform"
import { createFileRoute } from "@tanstack/react-router"
import { Console, Effect } from "effect"
import { use, useMemo } from "react"
export const Route = createFileRoute("/promise")({
component: RouteComponent
})
function RouteComponent() {
const runPromise = R.useRunPromise()
const promise = useMemo(() => HttpClient.HttpClient.pipe(
Effect.flatMap(client => client.get("https://www.uuidtools.com/api/generate/v4")),
HttpClient.withTracerPropagation(false),
Effect.flatMap(res => res.json),
Effect.tap(Console.log),
Effect.scoped,
runPromise,
), [runPromise])
const value = use(promise)
return <div>Hello "/tests"!</div>
}

View File

@@ -2,7 +2,7 @@ import { R } from "@/reffuse"
import { createFileRoute } from "@tanstack/react-router" import { createFileRoute } from "@tanstack/react-router"
import { GetRandomValues, makeUuid4 } from "@typed/id" import { GetRandomValues, makeUuid4 } from "@typed/id"
import { Console, Effect } from "effect" import { Console, Effect } from "effect"
import { useEffect, useState } from "react" import { useMemo, useState } from "react"
export const Route = createFileRoute("/tests")({ export const Route = createFileRoute("/tests")({
@@ -22,20 +22,16 @@ function RouteComponent() {
// )) // ))
const runPromise = R.useRunPromise() const runPromise = R.useRunPromise()
const [promise, setPromise] = useState<Promise<void> | null>(null)
const [, setValue] = useState("") const [, setValue] = useState("")
useEffect(() => { const promise = useMemo(() => makeUuid4.pipe(
makeUuid4.pipe(
Effect.provide(GetRandomValues.CryptoRandom), Effect.provide(GetRandomValues.CryptoRandom),
Effect.tap(id => Effect.sync(() => setValue(id))), Effect.tap(id => Effect.sync(() => setValue(id))),
Effect.andThen(Console.log), Effect.andThen(Console.log),
Effect.delay("1 second"), Effect.delay("1 second"),
runPromise, runPromise,
setPromise, ), [runPromise])
)
}, [runPromise])
console.log(promise) console.log(promise)