Types
Interfaces¶
ParsedResponse¶
Defined in: types/index.ts:202
Properties¶
| Property | Type | Defined in |
|---|---|---|
rsp |
Response |
types/index.ts:203 |
json |
PageResponse |
types/index.ts:204 |
Defer¶
Defined in: types/index.ts:228
Defer is a node in the page response thats been intentionally filled with empty or placeholder data for the purposes of fetching it later.
You would typically use it with props_template for parts of a page that you know would be slower to load.
Properties¶
| Property | Type | Description | Defined in |
|---|---|---|---|
url |
string |
A url with props_at keypath in the query parameter to indicate how to dig for the data, and where to place the data. | types/index.ts:229 |
type |
"auto" | "manual" |
When set to auto Superglue will automatically make the request using the url. When set to manual, Superglue does nothing, and you would need to manually use remote with the url to fetch the missing data. |
types/index.ts:230 |
path |
string |
A keypath indicates how to dig for the data and where to place the data. | types/index.ts:231 |
successAction |
string |
a user defined action for Superglue to dispatch when auto deferement is successful | types/index.ts:232 |
failAction |
string |
a user defined action for Superglue to dispatch when auto deferement failed | types/index.ts:233 |
GraftResponse\<T>¶
Defined in: types/index.ts:269
The GraftResponse is responsible for partial updates using props_template's digging functionality in Superglue.
Type Parameters¶
| Type Parameter | Default type |
|---|---|
T |
JSONMappable |
Properties¶
| Property | Type | Description | Defined in |
|---|---|---|---|
data |
T |
- | types/index.ts:270 |
componentIdentifier |
string |
- | types/index.ts:271 |
assets |
string[] |
- | types/index.ts:272 |
csrfToken? |
string |
- | types/index.ts:273 |
fragments |
FragmentPath[] |
- | types/index.ts:274 |
defers |
Defer[] |
- | types/index.ts:275 |
flash |
FlashState |
- | types/index.ts:276 |
action |
"graft" |
- | types/index.ts:277 |
renderedAt |
number |
- | types/index.ts:278 |
path |
string |
Used by superglue to replace the data at that location. | types/index.ts:280 |
fragmentContext? |
string |
- | types/index.ts:281 |
FragmentPath¶
Defined in: types/index.ts:318
A FragmentPath identifies a fragment inside of a PageResponse. Its used internally by Superglue to denormalize a page response into fragments, if any.
Properties¶
| Property | Type | Description | Defined in |
|---|---|---|---|
id |
string |
- | types/index.ts:319 |
path |
string |
A Keypath specifying the location of the fragment | types/index.ts:320 |
FragmentRef\<T, Present>¶
Defined in: types/index.ts:331
A FragmentRef is a reference to a Fragment.
Type Parameters¶
| Type Parameter | Default type |
|---|---|
T |
unknown |
Present extends boolean |
false |
Properties¶
| Property | Type | Description | Defined in |
|---|---|---|---|
__ref |
true |
- | types/index.ts:332 |
__id |
string |
A user supplied string identifying the fragment. This is usually created using props_template | types/index.ts:333 |
__type? |
T |
- | types/index.ts:334 |
__present? |
Present |
- | types/index.ts:335 |
SuperglueState¶
Defined in: types/index.ts:354
A read only state that contains meta information about the current page.
Properties¶
| Property | Type | Description | Defined in |
|---|---|---|---|
currentPageKey |
string |
The PageKey (url pathname + search) of the current page. This can be pass to Remote. | types/index.ts:356 |
search |
Record\<string, string | undefined> |
The query string object of the current url. | types/index.ts:358 |
csrfToken? |
string |
The Rails csrfToken that you can use for forms. | types/index.ts:360 |
assets |
string[] |
The tracked asset digests. | types/index.ts:362 |
RootState\<T>¶
Defined in: types/index.ts:369
The root state for a Superglue application. It occupies 2 keys in your app.
Type Parameters¶
| Type Parameter | Default type |
|---|---|
T |
JSONMappable |
Indexable¶
[name: string]: unknown
Properties¶
| Property | Type | Description | Defined in |
|---|---|---|---|
superglue |
SuperglueState |
Contains readonly metadata about the current page | types/index.ts:371 |
pages |
AllPages\<T> |
Every PageResponse that superglue recieves is stored here. | types/index.ts:373 |
fragments |
AllFragments |
- | types/index.ts:374 |
flash |
FlashState |
- | types/index.ts:375 |
Result¶
Defined in: types/index.ts:384
The success branch of a remote call. Resolved by the remote thunk
and webRemote; the hasError: false literal acts as the
discriminant for narrowing against ErrorResult.
Extended by¶
Properties¶
| Property | Type | Description | Defined in |
|---|---|---|---|
hasError |
false |
- | types/index.ts:385 |
pageKey |
string |
The URL of the response converted to a pageKey. Superglue uses this to persist the SaveResponse to store, when that happens. | types/index.ts:390 |
page |
PageResponse |
The SaveResponse of the page | types/index.ts:392 |
redirected |
boolean |
Indicates if response was redirected | types/index.ts:394 |
rsp |
Response |
The original response object | types/index.ts:396 |
fetchArgs |
FetchArgs |
The original args passed to fetch. | types/index.ts:398 |
componentIdentifier? |
string |
The ComponentIdentifier extracted from the response. | types/index.ts:400 |
needsRefresh |
boolean |
true when assets locally are detected to be out of date |
types/index.ts:402 |
VisitResult¶
Defined in: types/index.ts:409
The success branch of a visit call. Extends Result with the
computed NavigationAction for browser-history orchestration.
Extends¶
Properties¶
| Property | Type | Description | Inherited from | Defined in |
|---|---|---|---|---|
hasError |
false |
- | Result.hasError |
types/index.ts:385 |
pageKey |
string |
The URL of the response converted to a pageKey. Superglue uses this to persist the SaveResponse to store, when that happens. | Result.pageKey |
types/index.ts:390 |
page |
PageResponse |
The SaveResponse of the page | Result.page |
types/index.ts:392 |
redirected |
boolean |
Indicates if response was redirected | Result.redirected |
types/index.ts:394 |
rsp |
Response |
The original response object | Result.rsp |
types/index.ts:396 |
fetchArgs |
FetchArgs |
The original args passed to fetch. | Result.fetchArgs |
types/index.ts:398 |
componentIdentifier? |
string |
The ComponentIdentifier extracted from the response. | Result.componentIdentifier |
types/index.ts:400 |
needsRefresh |
boolean |
true when assets locally are detected to be out of date |
Result.needsRefresh |
types/index.ts:402 |
navigationAction |
NavigationAction |
The NavigationAction. This can be used for navigation. | - | types/index.ts:411 |
ErrorResult¶
Defined in: types/index.ts:419
The error branch returned by visit and remote when the server
responds with a non-2xx status. Non-HTTP failures (network, parse,
abort, programming bugs) propagate as a rejected promise instead.
Properties¶
| Property | Type | Description | Defined in |
|---|---|---|---|
hasError |
true |
- | types/index.ts:420 |
response |
Response |
The failed HTTP response. | types/index.ts:422 |
Handlers¶
Defined in: types/index.ts:471
Properties¶
| Property | Type | Defined in |
|---|---|---|
onClick |
(event: MouseEvent\<HTMLDivElement, MouseEvent>) => void |
types/index.ts:472 |
onSubmit |
(event: FormEvent\<HTMLDivElement>) => void |
types/index.ts:473 |
HistoryState¶
Defined in: types/index.ts:493
The state that is saved to history.state. Superglue stores information about the current page so that it can restore the page state when navigating back
Properties¶
| Property | Type | Description | Defined in |
|---|---|---|---|
superglue |
true |
Is always true so superglue can differentiate pages that have superglue enabled or not |
types/index.ts:495 |
pageKey |
string |
The page key in SuperglueState to restore from | types/index.ts:497 |
posX |
number |
The scroll position X of the page | types/index.ts:499 |
posY |
number |
The scroll position Y of the page | types/index.ts:501 |
BasicRequestInit¶
Defined in: types/index.ts:532
A variation of RequestInit except the headers must be a regular object
Extends¶
RequestInit
Properties¶
| Property | Type | Description | Overrides | Defined in |
|---|---|---|---|---|
headers? |
{[key: string]: string; } |
A Headers object, an object literal, or an array of two-item arrays to set request's headers. | RequestInit.headers |
types/index.ts:533 |
CopyTo()¶
Defined in: types/index.ts:582
Superglue comes with a Navigation component that provides a context with access to Visit, Remote and other useful tooling.
You can also use this to build your own <Link> component.
CopyTo(
path:string):void
Defined in: types/index.ts:582
Superglue comes with a Navigation component that provides a context with access to Visit, Remote and other useful tooling.
You can also use this to build your own <Link> component.
Parameters¶
| Parameter | Type |
|---|---|
path |
string |
Returns¶
void
NavigationProviderProps¶
Defined in: types/index.ts:600
Props for the Superglue navigation provider. Installs the history listener,
scroll restoration, and provides NavigationContextProps to its
descendants. Wraps children so a layout (or any other tree) can sit
between the provider and the rendered page.
Properties¶
| Property | Type | Defined in |
|---|---|---|
history |
History |
types/index.ts:601 |
visit |
ApplicationVisit |
types/index.ts:602 |
remote |
ApplicationRemote |
types/index.ts:603 |
children? |
ReactNode |
types/index.ts:604 |
NavigationOutletProps¶
Defined in: types/index.ts:612
Props for the Superglue navigation outlet. Reads the current page from the
Superglue store and renders the matching component from mapping.
Properties¶
| Property | Type | Defined in |
|---|---|---|
mapping |
Record\<ComponentIdentifier, React.ComponentType> |
types/index.ts:613 |
BuildStore()¶
Defined in: types/index.ts:624
Provide this callback to CreateAppArgs returning a Redux store for
Superglue to use. This would be setup and generated for you in store.js. We
recommend using using Redux toolkit's configureStore to build the store.
BuildStore(
initialState:RootState,reducer: {superglue: (state:SuperglueState,action:Action) =>SuperglueState;pages: (state:AllPages,action:Action) =>AllPages;fragments: (state:AllFragments,action:Action) =>AllFragments;flash: (state:FlashState,action:Action) =>FlashState; }):SuperglueStore
Defined in: types/index.ts:625
Provide this callback to CreateAppArgs returning a Redux store for
Superglue to use. This would be setup and generated for you in store.js. We
recommend using using Redux toolkit's configureStore to build the store.
Parameters¶
| Parameter | Type | Description |
|---|---|---|
initialState |
RootState |
A preconfigured intial state to pass to your store. |
reducer |
{ superglue: (state: SuperglueState, action: Action) => SuperglueState; pages: (state: AllPages, action: Action) => AllPages; fragments: (state: AllFragments, action: Action) => AllFragments; flash: (state: FlashState, action: Action) => FlashState; } |
A preconfigured reducer |
reducer.superglue |
(state: SuperglueState, action: Action) => SuperglueState |
- |
reducer.pages |
(state: AllPages, action: Action) => AllPages |
- |
reducer.fragments |
(state: AllFragments, action: Action) => AllFragments |
- |
reducer.flash |
(state: FlashState, action: Action) => FlashState |
- |
Returns¶
BuildVisitAndRemote()¶
Defined in: types/index.ts:639
Provide this callback to CreateAppArgs. Receives a context object
containing visit and remote callables. Customize this function to add
progress bars, error reporting (Sentry), or app-specific error-page
redirects.
Be sure to returns a wrapped { visit, remote } pair that Superglue and UJS
use for navigation.
BuildVisitAndRemote(
context:BuildVisitAndRemoteContext): {visit:ApplicationVisit;remote:ApplicationRemote; }
Defined in: types/index.ts:640
Parameters¶
| Parameter | Type |
|---|---|
context |
BuildVisitAndRemoteContext |
Returns¶
{ visit: ApplicationVisit; remote: ApplicationRemote; }
A wrapped ApplicationVisit / ApplicationRemote pair.
| Name | Type | Defined in |
|---|---|---|
visit |
ApplicationVisit |
types/index.ts:641 |
remote |
ApplicationRemote |
types/index.ts:642 |
BuildVisitAndRemoteContext¶
Defined in: types/index.ts:652
The context passed to BuildVisitAndRemote
The visit and remote functions in this context will resolve to a VisitResult or ErrorResult.
Properties¶
| Property | Type | Description | Defined in |
|---|---|---|---|
navigateTo |
NavigateTo |
Navigates after a successful visit. Bound to the createApp instance. | types/index.ts:654 |
visit |
(path: string, options?: VisitProps) => Promise\<VisitResult | ErrorResult> |
Pre-bound visit. Returns a discriminated result. | types/index.ts:656 |
remote |
(path: string, options?: RemoteProps) => Promise\<Result | ErrorResult> |
Pre-bound remote. Returns a discriminated result. | types/index.ts:661 |
CreateAppArgs¶
Defined in: types/index.ts:669
Arguments for createApp. Combines per-request bootstrap state
(initialPage, baseUrl, path) with app-wide config (mapping,
history, cable, buildVisitAndRemote).
Properties¶
| Property | Type | Description | Defined in |
|---|---|---|---|
initialPage |
SaveResponse |
The global var SUPERGLUE_INITIAL_PAGE_STATE is set by your erb template, e.g., application/superglue.html.erb | types/index.ts:674 |
baseUrl |
string |
The base url prefixed to all calls made by visit and remote. |
types/index.ts:678 |
path |
string |
The path of the current page. It should equal to the location.pathname + location.search + location.hash |
types/index.ts:683 |
mapping |
Record\<string, React.ComponentType> |
A mapping between page identifiers and the React components that render them. The Outlet returned from createApp reads this mapping when rendering the current page. |
types/index.ts:689 |
buildVisitAndRemote |
BuildVisitAndRemote |
A factory function that returns a visit and remote function. All of Superglue and UJS will use these functions. You should customize the function, for example, to add a progress bar. |
types/index.ts:695 |
history? |
History |
An optional history object https://github.com/remix-run/history. If none is provided Superglue will create one for you. | types/index.ts:700 |
cable? |
Consumer |
An optional ActionCable-compatible Consumer used by useStreamSource for real-time streaming. Construct this in your application code with createConsumer from @rails/actioncable or createCable from @anycable/web and pass it in. If omitted, useStreamSource is a no-op. |
types/index.ts:708 |
devTools? |
boolean |
Enable Redux DevTools integration. Defaults to false. |
types/index.ts:712 |
CreateAppResult¶
Defined in: types/index.ts:728
The result of calling createApp: a Provider component that owns
the Superglue React tree, an Outlet component that renders the current
page from the configured mapping, and a ujs object containing UJS
click/submit handlers the caller can attach wherever they choose.
Properties¶
| Property | Type | Defined in |
|---|---|---|
Provider |
ComponentType\<ProviderProps> |
types/index.ts:729 |
Outlet |
ComponentType |
types/index.ts:730 |
ujs |
Handlers |
types/index.ts:731 |
Type Aliases¶
ValidateOption¶
ValidateOption = {
validate?: (data:unknown) =>void; }
Defined in: types/index.ts:28
Options for runtime type validation in useContent and useFragment.
The validate callback is typically injected at build time by a
Superglue unplugin, but can also be passed manually with any
validation library. The callback should report errors via
console.error or by throwing.
Properties¶
validate()?¶
optionalvalidate: (data:unknown) =>void
Defined in: types/index.ts:29
Parameters¶
| Parameter | Type |
|---|---|
data |
unknown |
Returns¶
void
PageKey¶
PageKey =
string
Defined in: types/index.ts:38
A PageKey is a combination of a parsed URL's pathname + query string. No hash.
*
Example¶
RestoreStrategy¶
RestoreStrategy =
"fromCacheOnly"|"revisitOnly"|"fromCacheAndRevisitInBackground"
Defined in: types/index.ts:54
Defines the behavior when navigating to a page that is already stored on the client. For example, when navigating back.
When the page already exists in the store:
- fromCacheOnly - Use the cached page that exists on the store, only.
- revisitOnly - Ignore the cache and make a request for the latest page. If
the response was 200, the NavigationAction would be none as we don't want
to push into history. If the response was redirected, the NavigationAction would be set to
replace.
- fromCacheAndRevisitInBackground - Use the cache version of the page so
superglue can optimistically navigate to it, then make an additional request
for the latest version.
NavigationAction¶
NavigationAction =
"push"|"replace"|"none"
Defined in: types/index.ts:63
A NavigationAction is used to tell Superglue to history.push, history.replace or do nothing.
ComponentIdentifier¶
ComponentIdentifier =
string
Defined in: types/index.ts:69
An identifier that Superglue will uses to determine which page component to render with your page response.
Keypath¶
Keypath =
string
Defined in: types/index.ts:93
A keypath is a string representing the location of a piece of data. Superglue uses the keypath to dig for or update data.
Examples¶
Object access
Array access
Array with lookahead
JSONPrimitive¶
JSONPrimitive =
string|number|boolean|null|undefined
Defined in: types/index.ts:100
A JSON Primitive value
JSONObject¶
JSONObject = {[
key:string]:JSONValue; }
Defined in: types/index.ts:105
A JSON Object
Index Signature¶
[key: string]: JSONValue
JSONMappable¶
JSONMappable =
JSONValue[] |JSONObject
Defined in: types/index.ts:112
A JSON Object or an array of values
JSONKeyable¶
JSONKeyable =
JSONObject[] |JSONObject
Defined in: types/index.ts:117
A array of JSON key value objects or a JSON Object
JSONValue¶
JSONValue =
JSONPrimitive|JSONMappable
Defined in: types/index.ts:122
A primitive or a mappable object
FlashState¶
FlashState =
Record\<string,JSONValue>
Defined in: types/index.ts:124
Fragment\<T, Present>¶
Fragment\<
T,Present> =Presentextendstrue?T& {__id:string; } :T& {__id:string; } |undefined
Defined in: types/index.ts:182
A Fragment is a rendered Rails partial with an identity. The use of this type is optional, but it makes usage with unproxy and useUpdateFragment type friendly.
In general, Fragments enable normalized state management where Rails partials become referenceable entities on the client. The server renders partials as fragments with unique IDs, then Superglue normalizes them into a separate fragments store while replacing the original data with fragment references.
Type Parameters¶
| Type Parameter | Default type | Description |
|---|---|---|
T |
- | The shape of the fragment's data. |
Present |
false |
Indicates whether the fragment is guaranteed to be present. It's possible that a fragment was deleted from the store due to client side mutations. If you are sure that the fragment will ALWAYS be present, set this to true, otherwise its false by default. |
Examples¶
{
"data": { "cart": { items: [...], totalCost: 69.97 } },
"fragments": [{ "type": "userCart", "path": ["cart"] }]
}
{
pages: { "/page": { data: { cart: { __id: "userCart" } } } },
fragments: { "userCart": { items: [...], totalCost: 69.97 } }
}
type PageData = {
cart: Fragment<{ items: Item[]; totalCost: number }, true>;
user?: Fragment<{ name: string; email: string }>; // Optional fragment
}
const content = useContent<PageData>()
const cart = content.cart // Resolves fragment reference to actual data
// You can also nest fragments within other fragments
interface Post {
title: string
author: Fragment<Author, true>
comments: Array<Fragment<Comment, true>>
}
const page = useContent<{ post: Fragment<Post, true> }>()
Unproxy\<T>¶
Unproxy\<
T> =TextendsFragment\<infer U, infer P> ?Pextendsboolean?FragmentRef\<U,P> :FragmentRef\<U,false> :Textends infer U[] ?Unproxy\<U>[] :Textendsobject?{ [K in keyof T]: Unproxy<T[K]> }:T
Defined in: types/index.ts:190
Utility type for unproxy that converts Fragment types to fragment references.
This recursively processes objects and arrays to convert Fragment
Type Parameters¶
| Type Parameter |
|---|
T |
SaveResponse\<T>¶
SaveResponse\<
T> = {data:T;componentIdentifier:ComponentIdentifier;assets:string[];csrfToken?:string;fragments:FragmentPath[];defers:Defer[];flash:FlashState;action:"savePage";renderedAt:number;restoreStrategy:RestoreStrategy; }
Defined in: types/index.ts:240
The SaveResponse response is responsible for persisting a full page visit in Superglue.
Type Parameters¶
| Type Parameter | Default type |
|---|---|
T |
JSONMappable |
Properties¶
data¶
data:
T
Defined in: types/index.ts:241
componentIdentifier¶
componentIdentifier:
ComponentIdentifier
Defined in: types/index.ts:242
assets¶
assets:
string[]
Defined in: types/index.ts:243
csrfToken?¶
optionalcsrfToken:string
Defined in: types/index.ts:244
fragments¶
fragments:
FragmentPath[]
Defined in: types/index.ts:245
defers¶
defers:
Defer[]
Defined in: types/index.ts:246
flash¶
flash:
FlashState
Defined in: types/index.ts:247
action¶
action:
"savePage"
Defined in: types/index.ts:248
renderedAt¶
renderedAt:
number
Defined in: types/index.ts:250
restoreStrategy¶
restoreStrategy:
RestoreStrategy
Defined in: types/index.ts:251
Page\<T>¶
Page\<
T> =SaveResponse\<T> & {savedAt:number; }
Defined in: types/index.ts:257
A Page is a SaveResponse that's been saved to the store
Type declaration¶
| Name | Type | Defined in |
|---|---|---|
savedAt |
number |
types/index.ts:258 |
Type Parameters¶
| Type Parameter | Default type |
|---|---|
T |
JSONMappable |
StreamMessage¶
StreamMessage = {
data:JSONMappable;fragmentIds:string[];handler:"append"|"prepend"|"update";options:Record\<string,string>; }
Defined in: types/index.ts:284
Properties¶
data¶
data:
JSONMappable
Defined in: types/index.ts:285
fragmentIds¶
fragmentIds:
string[]
Defined in: types/index.ts:286
handler¶
handler:
"append"|"prepend"|"update"
Defined in: types/index.ts:287
options¶
options:
Record\<string,string>
Defined in: types/index.ts:288
StreamResponse¶
StreamResponse = {
data:StreamMessage[];fragments:FragmentPath[];assets:string[];csrfToken?:string;action:"handleStreamResponse";renderedAt:number;flash:FlashState; }
Defined in: types/index.ts:291
Properties¶
data¶
data:
StreamMessage[]
Defined in: types/index.ts:292
fragments¶
fragments:
FragmentPath[]
Defined in: types/index.ts:293
assets¶
assets:
string[]
Defined in: types/index.ts:294
csrfToken?¶
optionalcsrfToken:string
Defined in: types/index.ts:295
action¶
action:
"handleStreamResponse"
Defined in: types/index.ts:296
renderedAt¶
renderedAt:
number
Defined in: types/index.ts:297
flash¶
flash:
FlashState
Defined in: types/index.ts:298
PageResponse¶
PageResponse =
GraftResponse|SaveResponse|StreamResponse
Defined in: types/index.ts:306
A PageResponse can be either a GraftResponse, SaveResponse. or a StreamResponse Its meant to be implemented by the server and if you are using superglue_rails, the generators will handle all cases.
AllPages\<T>¶
Defined in: types/index.ts:342
The store where all page responses are stored indexed by PageKey. You are encouraged to mutate the Pages in this store.
Type Parameters¶
| Type Parameter | Default type |
|---|---|
T |
JSONMappable |
AllFragments¶
AllFragments =
Record\<string,JSONMappable>
Defined in: types/index.ts:348
The store where all page responses are stored indexed by PageKey. You are encouraged to mutate the Pages in this store.
VisitCreator()¶
VisitCreator = (
input:string|PageKey,options?:VisitProps) =>VisitMetaThunk
Defined in: types/index.ts:431
VisitCreator is a Redux action creator that returns a thunk. Use this to build
the Visit function. Typically it's already generated in application_visit.js
Parameters¶
| Parameter | Type |
|---|---|
input |
string | PageKey |
options? |
VisitProps |
Returns¶
RemoteCreator()¶
RemoteCreator = (
input:string|PageKey,options?:RemoteProps) =>MetaThunk
Defined in: types/index.ts:440
RemoteCreator is a Redux action creator that returns a thunk. Use this to build
the Remote function. Typically it's already generated in application_visit.js
Parameters¶
| Parameter | Type |
|---|---|
input |
string | PageKey |
options? |
RemoteProps |
Returns¶
Dispatch¶
Dispatch =
ThunkDispatch\<RootState,ExtraArgument,Action>
Defined in: types/index.ts:451
SuperglueStore¶
SuperglueStore =
EnhancedStore\<RootState,Action,Tuple\<[StoreEnhancer\<{dispatch:Dispatch; }>,StoreEnhancer]>>
Defined in: types/index.ts:458
A Store created with Redux Toolkit's configureStore setup with reducers
from Superglue. If you are using superglue_rails this would have been
generated for you in store.js and setup correctly in application.js
UJSHandlers()¶
UJSHandlers = (
{ ujsAttributePrefix, visit, remote, store, }: {ujsAttributePrefix:string;visit:ApplicationVisit;remote:ApplicationRemote;store:SuperglueStore; }) =>Handlers
Defined in: types/index.ts:476
Parameters¶
| Parameter | Type |
|---|---|
{ ujsAttributePrefix, visit, remote, store, } |
{ ujsAttributePrefix: string; visit: ApplicationVisit; remote: ApplicationRemote; store: SuperglueStore; } |
{ ujsAttributePrefix, visit, remote, store, }.ujsAttributePrefix |
string |
{ ujsAttributePrefix, visit, remote, store, }.visit |
ApplicationVisit |
{ ujsAttributePrefix, visit, remote, store, }.remote |
ApplicationRemote |
{ ujsAttributePrefix, visit, remote, store, }.store |
SuperglueStore |
Returns¶
SaveAndProcessPageThunk¶
SaveAndProcessPageThunk =
ThunkAction\<Promise\<void>,RootState,ExtraArgument,Action>
Defined in: types/index.ts:504
MetaThunk¶
MetaThunk =
ThunkAction\<Promise\<Result|ErrorResult>,RootState,ExtraArgument,Action>
Defined in: types/index.ts:511
VisitMetaThunk¶
VisitMetaThunk =
ThunkAction\<Promise\<VisitResult|ErrorResult>,RootState,ExtraArgument,Action>
Defined in: types/index.ts:517
DefermentThunk¶
DefermentThunk =
ThunkAction\<Promise\<void[]>,RootState,ExtraArgument,Action>
Defined in: types/index.ts:524
NavigateTo()¶
NavigateTo = (
path:Keypath,options?: {action?:NavigationAction;updateContent?: (draft:JSONMappable) =>void; }) =>boolean
Defined in: types/index.ts:562
Passed to every page component and also available as part of a NavigationContext:
import { NavigationContext } from '@thoughtbot/superglue';
const { navigateTo } = useContext(NavigationContext)
Manually navigate using pages that exists in the store and restores scroll
position. navigateTo is what Visit in your application_visit.js
ultimately calls.
If there is an existing page in your store navigateTo will restore the props,
render the correct component, and return true. Otherwise, it will return
false. This is useful if you want to restore an existing page before making a
call to visit or remote.
Parameters¶
| Parameter | Type | Description |
|---|---|---|
path |
Keypath |
|
options? |
{ action?: NavigationAction; updateContent?: (draft: JSONMappable) => void; } |
- |
options.action? |
NavigationAction |
when none, navigateTo will immediately return false |
options.updateContent? |
(draft: JSONMappable) => void |
- |
Returns¶
boolean
true if the navigation was a success, false if the page was not found in the
store.
NavigationContextProps¶
NavigationContextProps = {
navigateTo:NavigateTo;copyTo:CopyTo;visit:ApplicationVisit;remote:ApplicationRemote;pageKey:SuperglueState["currentPageKey"];search:SuperglueState["search"]; }
Defined in: types/index.ts:584
Properties¶
navigateTo¶
navigateTo:
NavigateTo
Defined in: types/index.ts:585
copyTo¶
copyTo:
CopyTo
Defined in: types/index.ts:586
visit¶
visit:
ApplicationVisit
Defined in: types/index.ts:587
remote¶
remote:
ApplicationRemote
Defined in: types/index.ts:588
pageKey¶
pageKey:
SuperglueState["currentPageKey"]
Defined in: types/index.ts:589
search¶
search:
SuperglueState["search"]
Defined in: types/index.ts:590
ProviderProps¶
ProviderProps = {
children?:React.ReactNode; }
Defined in: types/index.ts:718
Props for the Provider component returned from createApp.
Properties¶
children?¶
optionalchildren:React.ReactNode
Defined in: types/index.ts:719
References¶
FetchArgs¶
Re-exports FetchArgs
GraftingSuccessAction¶
Re-exports GraftingSuccessAction
GraftingErrorAction¶
Re-exports GraftingErrorAction
ChannelNameWithParams¶
Re-exports ChannelNameWithParams
ChannelMixin¶
Re-exports ChannelMixin
Subscription¶
Re-exports Subscription
Subscriptions¶
Re-exports Subscriptions
Consumer¶
Re-exports Consumer
Visit¶
Re-exports Visit
VisitProps¶
Re-exports VisitProps
Remote¶
Re-exports Remote
RemoteProps¶
Re-exports RemoteProps
BeforeSave¶
Re-exports BeforeSave
ApplicationRemote¶
Re-exports ApplicationRemote
ApplicationVisit¶
Re-exports ApplicationVisit