Skip to content

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

ApplicationBase

Overrides

React.Component<ApplicationProps>.constructor

Defined in

lib/index.tsx:154

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

lib/index.tsx:214

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

lib/index.tsx:220

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

lib/index.tsx:235

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

SuperglueStore

Defined in

lib/index.tsx:251

createHistory()

createHistory(): BrowserHistory

Returns

BrowserHistory

Defined in

lib/index.tsx:256

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

lib/index.tsx:273

render()

render(): Element

Returns

Element

Overrides

React.Component.render

Defined in

lib/index.tsx:275

Variables

GRAFTING_ERROR

const GRAFTING_ERROR: "@@superglue/GRAFTING_ERROR" = '@@superglue/GRAFTING_ERROR'

Defined in

lib/actions.ts:11


GRAFTING_SUCCESS

const GRAFTING_SUCCESS: "@@superglue/GRAFTING_SUCCESS" = '@@superglue/GRAFTING_SUCCESS'

Defined in

lib/actions.ts:12

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

lib/actions.ts:14


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

lib/actions.ts:46


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

lib/actions.ts:50


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

lib/actions.ts:54


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

lib/actions.ts:58


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

lib/actions.ts:62


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

lib/actions.ts:67


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

lib/middleware.ts:15


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

JSONValue

Defined in

lib/utils/immutability.ts:22


urlToPageKey()

urlToPageKey(url: string): PageKey

Converts a url to a PageKey.

Parameters

Parameter Type Description
url string

Returns

PageKey

Defined in

lib/utils/url.ts:57