mirror of
https://github.com/re-rxjs/react-rxjs.git
synced 2025-12-08 18:01:51 +00:00
export missing types
This commit is contained in:
parent
c75896006f
commit
ed4c2a49c4
@ -24,7 +24,7 @@
|
||||
"dist"
|
||||
],
|
||||
"scripts": {
|
||||
"build": "npm run build:ts && npm run build:esm2017 && npm run build:esm2019 && npm run build:cjs:dev && npm run build:cjs:prod",
|
||||
"build": "npm run build:ts && npm run build:esm2017 && npm run build:esm2019",
|
||||
"build:esm2019": "esbuild src/index.tsx --bundle --outfile=./dist/context-state.es2019.mjs --target=es2019 --external:react --external:rxjs --external:use-sync-external-store --format=esm --sourcemap",
|
||||
"build:esm2017": "esbuild src/index.tsx --bundle --outfile=./dist/context-state.es2017.js --target=es2017 --external:react --external:rxjs --external:use-sync-external-store --format=esm --sourcemap",
|
||||
"build:cjs:dev": "node cjsBuild.js",
|
||||
|
||||
@ -1,2 +1,7 @@
|
||||
export * from "./types"
|
||||
export * from "./combineStates"
|
||||
export * from "./create-signal"
|
||||
export * from "./create-root"
|
||||
export * from "./route-state"
|
||||
export * from "./substate"
|
||||
export * from "./types"
|
||||
export { StatePromise } from "./internal/promisses"
|
||||
|
||||
@ -6,7 +6,7 @@ import {
|
||||
} from "./internal"
|
||||
import { of } from "rxjs"
|
||||
import { substate } from "./substate"
|
||||
import { StateNode, CtxFn, StringRecord } from "./types"
|
||||
import { StateNode, GetValueFn, StringRecord } from "./types"
|
||||
|
||||
export class InvalidRouteError extends Error {
|
||||
constructor(key: string, keys: string[]) {
|
||||
@ -33,12 +33,12 @@ export const routeState = <
|
||||
>(
|
||||
parent: StateNode<T, K>,
|
||||
routes: O,
|
||||
selector: (value: T, ctx: CtxFn<T, K>) => keyof O,
|
||||
selector: (value: T, ctx: GetValueFn) => string & keyof O,
|
||||
): [StateNode<keyof O, K>, OT] => {
|
||||
const internalParent = getInternals(parent)
|
||||
const keys = new Set(Object.keys(routes))
|
||||
const keyState = substate(parent, (ctx) => {
|
||||
const key = selector(ctx(parent), ctx as any) as string
|
||||
const key = selector(ctx(parent), ctx)
|
||||
if (!keys.has(key)) throw new InvalidRouteError(key, [...keys])
|
||||
return of(key)
|
||||
})
|
||||
|
||||
@ -28,8 +28,10 @@ interface GetObservableFn<K> {
|
||||
): Observable<T>
|
||||
}
|
||||
|
||||
export type GetValueFn = <CT>(node: StateNode<CT, any>) => CT
|
||||
|
||||
export type CtxFn<T, K extends StringRecord<any>> = (
|
||||
ctxValue: <CT>(node: StateNode<CT, any>) => CT,
|
||||
ctxValue: GetValueFn,
|
||||
ctxObservable: GetObservableFn<K>,
|
||||
key: K,
|
||||
) => Observable<T>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user