Superglue
Classes¶
abstract
ApplicationBase¶
The entry point to your superglue application. You should create a class (Application) that inherit from the ApplicationBase component and override the buildStore, mapping, and visitAndRemote methods.
This would be setup for you when installing Superglue at application.js
.
Extends¶
Component
\<ApplicationProps
>
Constructors¶
new ApplicationBase()¶
new ApplicationBase(
props
:ApplicationProps
):ApplicationBase
The constructor of the ApplicationBase
class.
Parameters¶
Parameter | Type | Description |
---|---|---|
props |
ApplicationProps |
Returns¶
Overrides¶
React.Component<ApplicationProps>.constructor
Defined in¶
Methods¶
visitAndRemote()¶
abstract
visitAndRemote(navigatorRef
:RefObject
\<default
>,store
:SuperglueStore
): {visit
:Visit
;remote
:Remote
; }
Override this method to return a visit and remote function. These functions will be used by Superglue to power its UJS attributes and passed to your page components. You may customize this functionality to your liking, e.g, adding a progress bar.
Parameters¶
Parameter | Type | Description |
---|---|---|
navigatorRef |
RefObject \<default > |
|
store |
SuperglueStore |
Returns¶
{visit
: Visit
;remote
: Remote
; }
Name | Type | Defined in |
---|---|---|
visit |
Visit |
lib/index.tsx:218 |
remote |
Remote |
lib/index.tsx:218 |
Defined in¶
componentDidMount()¶
componentDidMount():
void
Called immediately after a component is mounted. Setting state here will trigger re-rendering.
Returns¶
void
Overrides¶
React.Component.componentDidMount
Defined in¶
componentWillUnmount()¶
componentWillUnmount():
void
Called immediately before a component is destroyed. Perform any necessary cleanup in this method, such as
cancelled network requests, or cleaning up any DOM elements created in componentDidMount
.
Returns¶
void
Overrides¶
React.Component.componentWillUnmount
Defined in¶
buildStore()¶
abstract
buildStore(initialState
: {[key: string]
:JSONValue
;pages
:AllPages
; },reducer
: {superglue
:superglueReducer
;pages
:pageReducer
; }):SuperglueStore
Override this method and return 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 |
object |
A preconfigured intial state to pass to your store. |
initialState.pages |
AllPages |
- |
reducer |
object |
A preconfigured reducer |
reducer.superglue |
(state : Partial \<SuperglueState >, action : Action ) => Partial \<SuperglueState > |
- |
reducer.pages |
(state : AllPages , action : Action ) => AllPages |
- |
Returns¶
Defined in¶
createHistory()¶
createHistory():
BrowserHistory
Returns¶
BrowserHistory
Defined in¶
mapping()¶
abstract
mapping():Record
\<string
,ComponentType
\<{}>>
Override this method and return a mapping between a componentIdentifier and a PageComponent. This will be passed to Superglue to determine which Page component to render with which payload.
Returns¶
Record
\<string
, ComponentType
\<{}>>
Defined in¶
render()¶
render():
Element
Returns¶
Element
Overrides¶
React.Component.render
Defined in¶
Variables¶
GRAFTING_ERROR¶
const
GRAFTING_ERROR:"@@superglue/GRAFTING_ERROR"
='@@superglue/GRAFTING_ERROR'
Defined in¶
GRAFTING_SUCCESS¶
const
GRAFTING_SUCCESS:"@@superglue/GRAFTING_SUCCESS"
='@@superglue/GRAFTING_SUCCESS'
Defined in¶
Functions¶
saveResponse()¶
saveResponse(...
args
: [{pageKey
:string
;page
:VisitResponse
; }]): {}
Calling this redux#ActionCreator with Args
will return
an Action with a payload of type P
and (depending on the PrepareAction
method used) a meta
- and error
property of types M
and E
respectively.
Parameters¶
Parameter | Type |
---|---|
...args |
[{pageKey : string ;page : VisitResponse ; }] |
Returns¶
{}
Defined in¶
updateFragments()¶
updateFragments(
payload
: {changedFragments
:Record
\<string
,JSONValue
>; }): {}
Calling this redux#ActionCreator with an argument will
return a PayloadAction of type T
with a payload of P
Parameters¶
Parameter | Type |
---|---|
payload |
object |
payload.changedFragments |
Record \<string , JSONValue > |
Returns¶
{}
Defined in¶
copyPage()¶
copyPage(
payload
: {from
:string
;to
:string
; }): {}
Calling this redux#ActionCreator with an argument will
return a PayloadAction of type T
with a payload of P
Parameters¶
Parameter | Type |
---|---|
payload |
object |
payload.from |
string |
payload.to |
string |
Returns¶
{}
Defined in¶
removePage()¶
removePage(
payload
: {pageKey
:string
; }): {}
Calling this redux#ActionCreator with an argument will
return a PayloadAction of type T
with a payload of P
Parameters¶
Parameter | Type |
---|---|
payload |
object |
payload.pageKey |
string |
Returns¶
{}
Defined in¶
beforeFetch()¶
beforeFetch(
payload
: {fetchArgs
:FetchArgs
; }): {}
Calling this redux#ActionCreator with an argument will
return a PayloadAction of type T
with a payload of P
Parameters¶
Parameter | Type |
---|---|
payload |
object |
payload.fetchArgs |
FetchArgs |
Returns¶
{}
Defined in¶
beforeVisit()¶
beforeVisit(
payload
: {currentPageKey
:string
;fetchArgs
:FetchArgs
; }): {}
Calling this redux#ActionCreator with an argument will
return a PayloadAction of type T
with a payload of P
Parameters¶
Parameter | Type |
---|---|
payload |
object |
payload.currentPageKey |
string |
payload.fetchArgs |
FetchArgs |
Returns¶
{}
Defined in¶
beforeRemote()¶
beforeRemote(
payload
: {currentPageKey
:string
;fetchArgs
:FetchArgs
; }): {}
Calling this redux#ActionCreator with an argument will
return a PayloadAction of type T
with a payload of P
Parameters¶
Parameter | Type |
---|---|
payload |
object |
payload.currentPageKey |
string |
payload.fetchArgs |
FetchArgs |
Returns¶
{}
Defined in¶
fragmentMiddleware()¶
fragmentMiddleware(
api
:MiddlewareAPI
\<Dispatch
,RootState
>): (next
: (action
:unknown
) =>unknown
) => (action
:unknown
) =>unknown
Experimental
A middleware that will update all Fragment across the AllPages slice, if a fragment on any page was mutated.
Parameters¶
Parameter | Type |
---|---|
api |
MiddlewareAPI \<Dispatch , RootState > |
Returns¶
Function
Parameters¶
Parameter | Type |
---|---|
next |
(action : unknown ) => unknown |
Returns¶
Function
Parameters¶
Parameter | Type |
---|---|
action |
unknown |
Returns¶
unknown
Defined in¶
getIn()¶
getIn(
node
:JSONMappable
,path
:string
):JSONValue
Retrieves data from a JSON object using a Keypath
Parameters¶
Parameter | Type | Description |
---|---|---|
node |
JSONMappable |
|
path |
string |
Returns¶
Defined in¶
urlToPageKey()¶
urlToPageKey(
url
:string
):PageKey
Converts a url to a PageKey.
Parameters¶
Parameter | Type | Description |
---|---|---|
url |
string |