Skip to main content Link Search Menu Expand Document (external link)

Added in v1.0.0


Table of contents


utils

BeforeNavigationEvent

Signature

export declare const BeforeNavigationEvent: Schema.Struct<{
  type: Schema.Literal<["push", "replace", "reload", "traverse"]>
  from: Schema.Struct<{
    id: Schema.Schema<Uuid, string, never>
    key: Schema.Schema<Uuid, string, never>
    url: Schema.transformOrFail<typeof Schema.String, Schema.Schema<URL, URL, never>, never>
    state: typeof Schema.Unknown
    sameDocument: typeof Schema.Boolean
  }>
  delta: typeof Schema.Number
  to: Schema.Union<
    [
      Schema.SchemaClass<
        { readonly url: URL; readonly state: unknown; readonly sameDocument: boolean },
        { readonly url: string; readonly state: unknown; readonly sameDocument: boolean },
        never
      >,
      Schema.Struct<{
        id: Schema.Schema<Uuid, string, never>
        key: Schema.Schema<Uuid, string, never>
        url: Schema.transformOrFail<typeof Schema.String, Schema.Schema<URL, URL, never>, never>
        state: typeof Schema.Unknown
        sameDocument: typeof Schema.Boolean
      }>
    ]
  >
  info: typeof Schema.Unknown
}>

Added in v1.0.0

BeforeNavigationEvent (interface)

Signature

export interface BeforeNavigationEvent extends Schema.Schema.Type<typeof BeforeNavigationEvent> {}

Added in v1.0.0

BeforeNavigationEventJson (type alias)

Signature

export type BeforeNavigationEventJson = Schema.Schema.Encoded<typeof BeforeNavigationEvent>

Added in v1.0.0

BeforeNavigationHandler (type alias)

Signature

export type BeforeNavigationHandler<R, R2> = (
  event: BeforeNavigationEvent
) => Effect.Effect<
  Option.Option<Effect.Effect<unknown, RedirectError | CancelNavigation, R2>>,
  RedirectError | CancelNavigation,
  R
>

Added in v1.0.0

CanGoBack

Signature

export declare const CanGoBack: RefSubject.Computed<boolean, never, Navigation>

Added in v1.0.0

CanGoForward

Signature

export declare const CanGoForward: RefSubject.Computed<boolean, never, Navigation>

Added in v1.0.0

CancelNavigation (class)

Signature

export declare class CancelNavigation

Added in v1.0.0

CurrentEntries

Signature

export declare const CurrentEntries: RefSubject.Computed<readonly Destination[], never, Navigation>

Added in v1.0.0

CurrentEntry

Signature

export declare const CurrentEntry: RefSubject.Computed<Destination, never, Navigation>

Added in v1.0.0

CurrentPath

Signature

export declare const CurrentPath: RefSubject.Computed<string, never, Navigation>

Added in v1.0.0

Destination

Signature

export declare const Destination: Schema.Struct<{
  id: Schema.Schema<Uuid, string, never>
  key: Schema.Schema<Uuid, string, never>
  url: Schema.transformOrFail<typeof Schema.String, Schema.Schema<URL, URL, never>, never>
  state: typeof Schema.Unknown
  sameDocument: typeof Schema.Boolean
}>

Added in v1.0.0

Destination (interface)

Signature

export interface Destination extends Schema.Schema.Type<typeof Destination> {}

Added in v1.0.0

DestinationJson (type alias)

Signature

export type DestinationJson = Schema.Schema.Encoded<typeof Destination>

Added in v1.0.0

FileSchema

Signature

export declare const FileSchema: Schema.transformOrFail<
  Schema.Struct<{ _id: Schema.Literal<["File"]>; name: typeof Schema.String; data: typeof Schema.String }>,
  Schema.instanceOf<File>,
  never
>

Added in v1.0.0

FileSchemaFrom

Signature

export declare const FileSchemaFrom: Schema.Struct<{
  _id: Schema.Literal<["File"]>
  name: typeof Schema.String
  data: typeof Schema.String
}>

Added in v1.0.0

FileSchemaFrom (type alias)

Signature

export type FileSchemaFrom = Schema.Schema.Encoded<typeof FileSchemaFrom>

Added in v1.0.0

FormDataEvent

Signature

export declare const FormDataEvent: Schema.extend<
  Schema.Struct<{
    from: Schema.Struct<{
      id: Schema.Schema<Uuid, string, never>
      key: Schema.Schema<Uuid, string, never>
      url: Schema.transformOrFail<typeof Schema.String, Schema.Schema<URL, URL, never>, never>
      state: typeof Schema.Unknown
      sameDocument: typeof Schema.Boolean
    }>
  }>,
  Schema.Struct<{
    name: Schema.optionalWith<typeof Schema.String, { readonly as: "Option"; readonly nullable: true }>
    action: Schema.optionalWith<typeof Schema.String, { readonly as: "Option"; readonly nullable: true }>
    method: Schema.optionalWith<typeof Schema.String, { readonly as: "Option"; readonly nullable: true }>
    encoding: Schema.optionalWith<typeof Schema.String, { readonly as: "Option"; readonly nullable: true }>
    data: Schema.transform<
      Schema.Record$<
        typeof Schema.String,
        Schema.Union<
          [
            typeof Schema.String,
            Schema.transformOrFail<
              Schema.Struct<{ _id: Schema.Literal<["File"]>; name: typeof Schema.String; data: typeof Schema.String }>,
              Schema.instanceOf<File>,
              never
            >
          ]
        >
      >,
      Schema.instanceOf<FormData>
    >
  }>
>

Added in v1.0.0

FormDataEvent (interface)

Signature

export interface FormDataEvent extends Schema.Schema.Type<typeof FormDataEvent> {}

Added in v1.0.0

FormDataEventJson (type alias)

Signature

export type FormDataEventJson = Schema.Schema.Encoded<typeof FormDataEvent>

Added in v1.0.0

FormDataHandler (type alias)

Signature

export type FormDataHandler<R, R2> = (
  event: FormDataEvent
) => Effect.Effect<
  Option.Option<
    Effect.Effect<Option.Option<HttpClientResponse.HttpClientResponse>, RedirectError | CancelNavigation, R2>
  >,
  RedirectError | CancelNavigation,
  R
>

Added in v1.0.0

FormDataSchema

Signature

export declare const FormDataSchema: Schema.transform<
  Schema.Record$<
    typeof Schema.String,
    Schema.Union<
      [
        typeof Schema.String,
        Schema.transformOrFail<
          Schema.Struct<{ _id: Schema.Literal<["File"]>; name: typeof Schema.String; data: typeof Schema.String }>,
          Schema.instanceOf<File>,
          never
        >
      ]
    >
  >,
  Schema.instanceOf<FormData>
>

Added in v1.0.0

FormInput (interface)

Signature

export interface FormInput extends Schema.Schema.Type<typeof FormInputSchema> {}

Added in v1.0.0

FormInputFrom (type alias)

Signature

export type FormInputFrom = Schema.Schema.Encoded<typeof FormInputSchema>

Added in v1.0.0

FormInputSchema

Signature

export declare const FormInputSchema: Schema.Struct<{
  name: Schema.optionalWith<typeof Schema.String, { readonly as: "Option"; readonly nullable: true }>
  action: Schema.optionalWith<typeof Schema.String, { readonly as: "Option"; readonly nullable: true }>
  method: Schema.optionalWith<typeof Schema.String, { readonly as: "Option"; readonly nullable: true }>
  encoding: Schema.optionalWith<typeof Schema.String, { readonly as: "Option"; readonly nullable: true }>
  data: Schema.transform<
    Schema.Record$<
      typeof Schema.String,
      Schema.Union<
        [
          typeof Schema.String,
          Schema.transformOrFail<
            Schema.Struct<{ _id: Schema.Literal<["File"]>; name: typeof Schema.String; data: typeof Schema.String }>,
            Schema.instanceOf<File>,
            never
          >
        ]
      >
    >,
    Schema.instanceOf<FormData>
  >
}>

Added in v1.0.0

Signature

export interface NavigateOptions {
  readonly history?: "replace" | "push" | "auto"
  readonly state?: unknown
  readonly info?: unknown
}

Added in v1.0.0

Signature

export declare const Navigation: Tagged<Navigation, Navigation>

Added in v1.0.0

Signature

export interface Navigation {
  readonly origin: string

  readonly base: string

  readonly currentEntry: RefSubject.Computed<Destination>

  readonly entries: RefSubject.Computed<ReadonlyArray<Destination>>

  readonly transition: RefSubject.Computed<Option.Option<Transition>>

  readonly canGoBack: RefSubject.Computed<boolean>

  readonly canGoForward: RefSubject.Computed<boolean>

  readonly navigate: (url: string | URL, options?: NavigateOptions) => Effect.Effect<Destination, NavigationError>

  readonly back: (options?: { readonly info?: unknown }) => Effect.Effect<Destination, NavigationError>

  readonly forward: (options?: { readonly info?: unknown }) => Effect.Effect<Destination, NavigationError>

  readonly traverseTo: (
    key: Destination["key"],
    options?: { readonly info?: unknown }
  ) => Effect.Effect<Destination, NavigationError>

  readonly updateCurrentEntry: (options: { readonly state: unknown }) => Effect.Effect<Destination, NavigationError>

  readonly reload: (options?: {
    readonly info?: unknown
    readonly state?: unknown
  }) => Effect.Effect<Destination, NavigationError>

  readonly beforeNavigation: <R = never, R2 = never>(
    handler: BeforeNavigationHandler<R, R2>
  ) => Effect.Effect<void, never, R | R2 | Scope.Scope>

  readonly onNavigation: <R = never, R2 = never>(
    handler: NavigationHandler<R, R2>
  ) => Effect.Effect<void, never, R | R2 | Scope.Scope>

  readonly submit: (
    data: FormData,
    formInput?: Simplify<Omit<FormInputFrom, "data">>
  ) => Effect.Effect<
    Option.Option<HttpClientResponse.HttpClientResponse>,
    NavigationError | HttpClientError.HttpClientError,
    Scope.Scope | HttpClient.HttpClient.Service
  >

  readonly onFormData: <R = never, R2 = never>(
    handler: FormDataHandler<R, R2>
  ) => Effect.Effect<void, never, R | R2 | Scope.Scope>
}

Added in v1.0.0

Signature

export declare class NavigationError

Added in v1.0.0

Signature

export declare const NavigationEvent: Schema.Struct<{
  type: Schema.Literal<["push", "replace", "reload", "traverse"]>
  destination: Schema.Struct<{
    id: Schema.Schema<Uuid, string, never>
    key: Schema.Schema<Uuid, string, never>
    url: Schema.transformOrFail<typeof Schema.String, Schema.Schema<URL, URL, never>, never>
    state: typeof Schema.Unknown
    sameDocument: typeof Schema.Boolean
  }>
  info: typeof Schema.Unknown
}>

Added in v1.0.0

Signature

export interface NavigationEvent extends Schema.Schema.Type<typeof NavigationEvent> {}

Added in v1.0.0

Signature

export type NavigationEventJson = Schema.Schema.Encoded<typeof NavigationEvent>

Added in v1.0.0

Signature

export type NavigationHandler<R, R2> = (
  event: NavigationEvent
) => Effect.Effect<Option.Option<Effect.Effect<unknown, never, R2>>, never, R>

Added in v1.0.0

Signature

export declare const NavigationType: Schema.Literal<["push", "replace", "reload", "traverse"]>

Added in v1.0.0

Signature

export type NavigationType = Schema.Schema.Type<typeof NavigationType>

Added in v1.0.0

ProposedDestination

Signature

export declare const ProposedDestination: Schema.SchemaClass<
  { readonly url: URL; readonly state: unknown; readonly sameDocument: boolean },
  { readonly url: string; readonly state: unknown; readonly sameDocument: boolean },
  never
>

Added in v1.0.0

ProposedDestination (interface)

Signature

export interface ProposedDestination extends Schema.Schema.Type<typeof ProposedDestination> {}

Added in v1.0.0

ProposedDestinationJson (type alias)

Signature

export type ProposedDestinationJson = Schema.Schema.Encoded<typeof ProposedDestination>

Added in v1.0.0

RedirectError (class)

Signature

export declare class RedirectError

Added in v1.0.0

Transition

Signature

export declare const Transition: Schema.Struct<{
  type: Schema.Literal<["push", "replace", "reload", "traverse"]>
  from: Schema.Struct<{
    id: Schema.Schema<Uuid, string, never>
    key: Schema.Schema<Uuid, string, never>
    url: Schema.transformOrFail<typeof Schema.String, Schema.Schema<URL, URL, never>, never>
    state: typeof Schema.Unknown
    sameDocument: typeof Schema.Boolean
  }>
  to: Schema.Union<
    [
      Schema.SchemaClass<
        { readonly url: URL; readonly state: unknown; readonly sameDocument: boolean },
        { readonly url: string; readonly state: unknown; readonly sameDocument: boolean },
        never
      >,
      Schema.Struct<{
        id: Schema.Schema<Uuid, string, never>
        key: Schema.Schema<Uuid, string, never>
        url: Schema.transformOrFail<typeof Schema.String, Schema.Schema<URL, URL, never>, never>
        state: typeof Schema.Unknown
        sameDocument: typeof Schema.Boolean
      }>
    ]
  >
}>

Added in v1.0.0

Transition (interface)

Signature

export interface Transition extends Schema.Schema.Type<typeof Transition> {}

Added in v1.0.0

TransitionJson (type alias)

Signature

export type TransitionJson = Schema.Schema.Encoded<typeof Transition>

Added in v1.0.0

back

Signature

export declare const back: (options?: {
  readonly info?: unknown
}) => Effect.Effect<Destination, NavigationError, Navigation>

Added in v1.0.0

cancelNavigation

Signature

export declare const cancelNavigation: CancelNavigation

Added in v1.0.0

forward

Signature

export declare const forward: (options?: {
  readonly info?: unknown
}) => Effect.Effect<Destination, NavigationError, Navigation>

Added in v1.0.0

getCurrentPathFromUrl

Signature

export declare function getCurrentPathFromUrl(location: Pick<URL, "pathname" | "search" | "hash">): string

Added in v1.0.0

handleRedirect

Signature

export declare function handleRedirect(error: RedirectError)

Added in v1.0.0

isCancelNavigation

Signature

export declare function isCancelNavigation(e: unknown): e is CancelNavigation

Added in v1.0.0

isNavigationError

Signature

export declare function isNavigationError(e: unknown): e is NavigationError

Added in v1.0.0

isRedirectError

Signature

export declare function isRedirectError(e: unknown): e is RedirectError

Added in v1.0.0

Signature

export declare const navigate: (
  url: string | URL,
  options?: NavigateOptions
) => Effect.Effect<Destination, NavigationError, Navigation>

Added in v1.0.0

onFormData

Signature

export declare function onFormData<R = never, R2 = never>(
  handler: FormDataHandler<R, R2>
): Effect.Effect<void, never, Navigation | R | R2 | Scope.Scope>

Added in v1.0.0

redirectToPath

Signature

export declare function redirectToPath(
  path: string | URL,
  options?: { readonly state?: unknown; readonly info?: unknown }
): RedirectError

Added in v1.0.0

reload

Signature

export declare const reload: (options?: {
  readonly info?: unknown
  readonly state?: unknown
}) => Effect.Effect<Destination, NavigationError, Navigation>

Added in v1.0.0

submit

Signature

export declare function submit(
  data: FormData,
  formInput?: Simplify<Omit<FormInputFrom, "data">>
): Effect.Effect<
  Option.Option<HttpClientResponse.HttpClientResponse>,
  NavigationError | HttpClientError.HttpClientError,
  Navigation | HttpClient.HttpClient.Service | Scope.Scope
>

Added in v1.0.0

traverseTo

Signature

export declare const traverseTo: (
  key: Uuid,
  options?: { readonly info?: unknown }
) => Effect.Effect<Destination, NavigationError, Navigation>

Added in v1.0.0

updateCurrentEntry

Signature

export declare const updateCurrentEntry: (options: {
  readonly state: unknown
}) => Effect.Effect<Destination, NavigationError, Navigation>

Added in v1.0.0