Skip to content

Commit

Permalink
core: fix SUSPENSE typings
Browse files Browse the repository at this point in the history
  • Loading branch information
josepot committed Apr 25, 2022
1 parent 85ad4a3 commit e3d6f64
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
5 changes: 1 addition & 4 deletions packages/core/src/SUSPENSE.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,4 @@
* leverage React Suspense API while we are waiting for that value.
*/
export const SUSPENSE = Symbol("SUSPENSE")

export const filterOutSuspense = <T>(
value: T,
): value is Exclude<T, typeof SUSPENSE> => value !== (SUSPENSE as any)
export type SUSPENSE = typeof SUSPENSE
5 changes: 4 additions & 1 deletion packages/core/src/useStateObservable.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useRef, useState } from "react"
import { SUSPENSE, filterOutSuspense } from "./SUSPENSE"
import { SUSPENSE } from "./SUSPENSE"
import { DefaultedStateObservable, StateObservable } from "@rxstate/core"
import { EMPTY_VALUE } from "./internal/empty-value"
import useSyncExternalStore from "./internal/useSyncExternalStore"
Expand All @@ -12,6 +12,9 @@ interface Ref<T> {
args: [(cb: VoidCb) => VoidCb, () => Exclude<T, typeof SUSPENSE>]
}

const filterOutSuspense = <T>(value: T): value is Exclude<T, SUSPENSE> =>
value !== (SUSPENSE as any)

export const useStateObservable = <O>(
source$: StateObservable<O>,
): Exclude<O, typeof SUSPENSE> => {
Expand Down

0 comments on commit e3d6f64

Please sign in to comment.