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:215 |
remote |
Remote |
lib/index.tsx:215 |
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 : UnknownAction | SuperglueReducerAction ) => Partial \<SuperglueState > |
- |
reducer.pages |
(state : AllPages , action : UnknownAction | PageReducerAction ) => 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¶
BEFORE_FETCH¶
const
BEFORE_FETCH:"@@superglue/BEFORE_FETCH"
='@@superglue/BEFORE_FETCH'
Defined in¶
BEFORE_VISIT¶
const
BEFORE_VISIT:"@@superglue/BEFORE_VISIT"
='@@superglue/BEFORE_VISIT'
Defined in¶
BEFORE_REMOTE¶
const
BEFORE_REMOTE:"@@superglue/BEFORE_REMOTE"
='@@superglue/BEFORE_REMOTE'
Defined in¶
SAVE_RESPONSE¶
const
SAVE_RESPONSE:"@@superglue/SAVE_RESPONSE"
='@@superglue/SAVE_RESPONSE'
Defined in¶
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¶
HISTORY_CHANGE¶
const
HISTORY_CHANGE:"@@superglue/HISTORY_CHANGE"
='@@superglue/HISTORY_CHANGE'
Defined in¶
REMOVE_PAGE¶
const
REMOVE_PAGE:"@@superglue/REMOVE_PAGE"
='@@superglue/REMOVE_PAGE'
Defined in¶
COPY_PAGE¶
const
COPY_PAGE:"@@superglue/COPY_PAGE"
='@@superglue/COPY_PAGE'
Defined in¶
UPDATE_FRAGMENTS¶
const
UPDATE_FRAGMENTS:"@@superglue/UPDATE_FRAGMENTS"
='@@superglue/UPDATE_FRAGMENTS'
Defined in¶
Functions¶
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 |