Interfaces
Last updated
Was this helpful?
Last updated
Was this helpful?
Visit(
input
:string
,options
: ):Promise
<>
Use visit to make single page transitions from one page. The function is a wrapper around fetch and made to mimic a link click or a form submision. When used, a json
request will be made for the next page, then Superglue saves the response, swap the page component, and change the browser history.
!!! note There can be only one visit
at a time. If another visit
is called from elsewhere, the previous visit would be aborted.
You must provide the implentation and pass it back to Superglue in application.js
. Superglue will then pass it to your page components and use it for UJS navigation. This is usually generated for you in application_visit.js
where you can customize its behavior globally.
input
string
The first argument to Fetch
options
Promise
<>
Options for Visit
Omit
<BaseProps
, "signal"
>
placeholderKey?
string
Defaults to the currentPageKey. When present, Superglue will use the page state located at that pageKey and optimistally navigates to it as the next page's state while the requests resolves.
-
revisit?
boolean
When true
and the request method is a GET, changes the suggestionAction
of the Meta object to none
so that Superglue does nothing to window.history. When the GET response was redirected, changes navigationAction
to replace
-
method?
string
The HTTP method
Omit.method
body?
BodyInit
The HTTP body
Omit.body
headers?
{}
The HTTP headers
Omit.headers
beforeSave?
-
Omit.beforeSave
Remote is is wrapper around fetch. Its used to make a request and mutate the store. Remote does not navigate, and it does not change the browser history. There can be multiple Remote requests running concurrently.
input
string
The first argument to Fetch
options
The fetch RequestInit with additional options
Options for Visit
BaseProps
method?
string
The HTTP method
BaseProps.method
body?
BodyInit
The HTTP body
BaseProps.body
headers?
{}
The HTTP headers
BaseProps.headers
beforeSave?
-
BaseProps.beforeSave
pageKey?
string
-
force?
boolean
-
A callback that will be fire in between recieving a payload and saving a payload. Use this callback to modify the payload before it gets saved. Its useful for appending, prepending, shuffeling, etc. recieved data to existing data.
prevPage
receivedPage
The only difference between the two interfaces is ApplicationRemote will also be passed a dataset as an option. This is because Superglue UJS uses ApplicationRemote and will pass the dataset of the HTML element where UJS is enabled on.
input
string
options
The only difference between the two interfaces is ApplicationVisit will also be passed a dataset as an option. This is because Superglue UJS uses ApplicationVisit and will pass the dataset of the HTML element where UJS is enabled on.
input
string
options
Remote(input
: string
, options
: ): Promise
<>
This function is to be wrapped by a deverloper as a and returned to superglue. This is usually generated as application_visit.js
where you can make minimum edits to affect its global usage.
Promise
<>
Specifies where to store the remote payload, if not provided will derive a key from the response's url.
By default, remote disallows grafting a page response using props_at if the target pageKey provided has a different componentIdentifier. Setting force: true
will ignore this limitation. This can be useful if you are absolutely sure that the page your grafting onto has a compatible shape with the response received with using props_at. A good example of this is a shared global header.
BeforeSave(prevPage
: , receivedPage
: ):
ApplicationRemote(input
: string
, options
: & {dataset
: {}; }): Promise
<>
ApplicationRemote is the developer provided wrapper around .
It contains custom functionality, but is bound by the interface that Superglue uses to make a remote
call. See for more details.
& {dataset
: {}; }
Promise
<>
ApplicationVisit(input
: string
, options
: & {dataset
: {}; }): Promise
<undefined
| void
| >
ApplicationVisit is the developer provided wrapper around .
It contains custom functionality, but is bound by the interface that Superglue uses to make a visit
call. See for more details.
& {dataset
: {}; }
Promise
<undefined
| void
| >