index

References

useSuperglue

Re-exports useSuperglue

useContent

Re-exports useContent

Re-exports NavigationProvider

Re-exports NavigationContext

superglueReducer

Re-exports superglue

pageReducer

Re-exports pages

FetchArgs

Re-exports FetchArgs

GraftingSuccessAction

Re-exports GraftingSuccessAction

GraftingErrorAction

Re-exports GraftingErrorAction

PageKey

Re-exports PageKey

RestoreStrategy

Re-exports RestoreStrategy

Re-exports NavigationAction

ComponentIdentifier

Re-exports ComponentIdentifier

Keypath

Re-exports Keypath

JSONPrimitive

Re-exports JSONPrimitive

JSONObject

Re-exports JSONObject

JSONMappable

Re-exports JSONMappable

JSONKeyable

Re-exports JSONKeyable

JSONValue

Re-exports JSONValue

ParsedResponse

Re-exports ParsedResponse

Defer

Re-exports Defer

VisitResponse

Re-exports VisitResponse

Page

Re-exports Page

GraftResponse

Re-exports GraftResponse

PageResponse

Re-exports PageResponse

Fragment

Re-exports Fragment

AllPages

Re-exports AllPages

SuperglueState

Re-exports SuperglueState

RootState

Re-exports RootState

Meta

Re-exports Meta

VisitMeta

Re-exports VisitMeta

VisitCreator

Re-exports VisitCreator

RemoteCreator

Re-exports RemoteCreator

Dispatch

Re-exports Dispatch

SuperglueStore

Re-exports SuperglueStore

Handlers

Re-exports Handlers

UJSHandlers

Re-exports UJSHandlers

HistoryState

Re-exports HistoryState

SaveAndProcessPageThunk

Re-exports SaveAndProcessPageThunk

MetaThunk

Re-exports MetaThunk

VisitMetaThunk

Re-exports VisitMetaThunk

DefermentThunk

Re-exports DefermentThunk

BasicRequestInit

Re-exports BasicRequestInit

Re-exports NavigateTo

Re-exports NavigationContextProps

Re-exports NavigationProviderProps

BuildStore

Re-exports BuildStore

BuildVisitAndRemote

Re-exports BuildVisitAndRemote

SetupProps

Re-exports SetupProps

ApplicationProps

Re-exports ApplicationProps

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

Variables

GRAFTING_ERROR

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

Defined in

lib/actions.ts:12


GRAFTING_SUCCESS

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

Defined in

lib/actions.ts:13


rootReducer

const rootReducer: {superglue: superglueReducer;pages: pageReducer; }

Type declaration

Name
Type
Default value
Defined in

superglue

superglueReducer

pages

pageReducer

Defined in

lib/reducers/index.ts:235

Functions

saveAndProcessPage()

saveAndProcessPage(pageKey: string, page: VisitResponse | GraftResponse): SaveAndProcessPageThunk

Save and process a rendered view from PropsTemplate. This is the primitive function that visit and remote calls when it receives a page.

If you render a page outside the normal request response cycle, e.g, websocket, you can use this function to save the payload.

Parameters

Parameter
Type

pageKey

string

page

Returns

SaveAndProcessPageThunk

Defined in

lib/action_creators/index.ts:74


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

Returns

{}

Defined in

lib/actions.ts:15


updateFragments()

updateFragments(payload: {name: string;path: string;pageKey: string;value: JSONMappable;previousValue: JSONMappable; }): {}

A redux action called whenever a fragment is received from visit or updated using remote. Its a useful action to use for cross cutting concerns like a shared header or a shopping cart. For example:

import { updateFragments } from '@thoughtbot/superglue'

export const exampleSlice = createSlice({
 name: 'Example',
 initialState: {},
 extraReducers: (builder) => {
   builder.addCase(updateFragments, (state, action) => {
     // Update the slice using the latest and greatest.
     return action.value

Parameters

Parameter
Type

payload

object

payload.name

string

payload.path

string

payload.pageKey

string

payload.value

payload.previousValue?

Returns

{}

Defined in

lib/actions.ts:64


copyPage()

copyPage(payload: {from: string;to: string; }): {}

A redux action you can dispatch to copy a page from one pageKey to another. Its a very useful way to create optimistic updates with a URL change. For example:

import { copyPage, remote } from '@thoughtbot/superglue'

dispatch(copyPage({ from: originalKey, to: targetKey}))

... make edits to target page and finally

navigateTo(targetKey)

Parameters

Parameter
Type

payload

object

payload.from

string

payload.to

string

Returns

{}

Defined in

lib/actions.ts:86


removePage()

removePage(payload: {pageKey: string; }): {}

A redux action you can dispatch to remove a page from your store.

import { removePage } from '@thoughtbot/superglue'

dispatch(removePage({ pageKey: '/delete_me_please"}))

Parameters

Parameter
Type

payload

object

payload.pageKey

string

Returns

{}

Defined in

lib/actions.ts:99


beforeFetch()

beforeFetch(payload: {fetchArgs: FetchArgs; }): {}

A redux action called before a fetch takes place. It will fire in remote and visit. You can hook into this event in your redux slices like this:

import { beforeFetch } from '@thoughtbot/superglue'

export const exampleSlice = createSlice({
 name: 'Example',
 initialState: {},
 extraReducers: (builder) => {
   builder.addCase(beforeFetch, (state, action) => {

Parameters

Parameter
Type

payload

object

payload.fetchArgs

Returns

{}

Defined in

lib/actions.ts:117


beforeVisit()

beforeVisit(payload: {currentPageKey: string;fetchArgs: FetchArgs; }): {}

A redux action called before a visit takes place. You can hook into this event in your redux slices like this:

import { beforeVisit } from '@thoughtbot/superglue'

export const exampleSlice = createSlice({
 name: 'Example',
 initialState: {},
 extraReducers: (builder) => {
   builder.addCase(beforeVisit, (state, action) => {

Parameters

Parameter
Type

payload

object

payload.currentPageKey

string

payload.fetchArgs

Returns

{}

Defined in

lib/actions.ts:135


beforeRemote()

beforeRemote(payload: {currentPageKey: string;fetchArgs: FetchArgs; }): {}

A redux action called before remote takes place. You can hook into this event in your redux slices like this:

import { beforeRemote } from '@thoughtbot/superglue'

export const exampleSlice = createSlice({
 name: 'Example',
 initialState: {},
 extraReducers: (builder) => {
   builder.addCase(beforeRemote, (state, action) => {

Parameters

Parameter
Type

payload

object

payload.currentPageKey

string

payload.fetchArgs

Returns

{}

Defined in

lib/actions.ts:154


prepareStore()

prepareStore(store: SuperglueStore, initialPage: VisitResponse, path: string): void

Parameters

Parameter
Type

store

initialPage

path

string

Returns

void

Defined in

lib/index.tsx:51


setup()

setup(__namedParameters: SetupProps): {visit: ApplicationVisit;remote: ApplicationRemote;nextHistory: History;initialPageKey: string;ujs: handlers; }

This is the setup function that the Application calls. Use this function if you like to build your own Application component.

Parameters

Parameter
Type

__namedParameters

Returns

{visit: ApplicationVisit;remote: ApplicationRemote;nextHistory: History;initialPageKey: string;ujs: handlers; }

Name
Type
Default value
Defined in

visit

-

remote

-

nextHistory

History

-

initialPageKey

string

-

ujs

handlers

Defined in

lib/index.tsx:73


Application()

Application(__namedParameters: ApplicationProps): Element

The entry point to your superglue application. It sets up the redux Provider, redux state and the Navigation component.

This is a simple component, you can override this by copying the source code and use the exported methods used by this component (start and ujsHandler).

Parameters

Parameter
Type

__namedParameters

Returns

Element

Defined in

lib/index.tsx:114


getIn()

getIn(node: JSONMappable, path: string): JSONValue

Retrieves data from a JSON object using a Keypath

Parameters

Parameter
Type
Description

node

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:64

Last updated

Was this helpful?