Start typing to search...

PlayerState

Manages the state of the Koji player to enable distinct experiences for different users and views.

Methods

.hideChrome()

Hides any Koji player chrome, such as the user’s profile icon. To display the player chrome, use [[showChrome]].

Note
Incorrectly controlling the player chrome can result in a disorienting user experience, so use this functionality judiciously. The player chrome must be displayed on all root screens of an app. It can be hidden if a user navigates to a child screen, such as a modal. The player chrome is hidden by default when the app’s presentationStyle is popover.

Example

Koji.playerState.hideChrome();

Source: frontend/playerState/index.ts#L180

.onBlur(callback)

Listens for event notifications that the Koji app lost the focus and then invokes a callback function to respond to the focus state change.

Parameters

  • callback - BlurCallback, Function to handle when the Koji app loses the focus.

Returns

Function, Function to unsubscribe from the onBlur listener.

Example

const unsubscribeBlur = Koji.playerState.onBlur((blur) => {
 // Change Koji experience
});

Source: frontend/playerState/index.ts#L158

.onFocus(callback)

Listens for event notifications that the Koji app got the focus and then invokes a callback function to respond to the focus state change.

Parameters

  • callback - FocusCallback, Function to handle when the Koji app gets the focus.

Returns

Function, Function to unsubscribe from the onFocus listener.

Example

const unsubscribeFocus = Koji.playerState.onFocus((focus) => {
 // Change Koji experience
});

Source: frontend/playerState/index.ts#L135

.showChrome()

Restores the Koji platform chrome, if it has been hidden with [[hideChrome]].

Example

Koji.playerState.showChrome();

Source: frontend/playerState/index.ts#L196

.subscribe(callback)

Listens to changes in customization mode and invokes a callback function to enable different experiences during customization, preview, or use.

Parameters

Returns

Function, Function to unsubscribe from the customization mode listener.

Example

const unsubscribe = Koji.playerState.subscribe((remixing, { type, mode }) => {
 // Change Koji experience
});

Source: frontend/playerState/index.ts#L219

Properties

.context

PlayerStateContext, Context of the Koji app.

.hasFocus

Boolean, Focus state of the Koji app.

.isChromeVisible

Boolean, Whether the player chrome (Koji platform buttons and navigation) is visible.

.presentationStyle

PlayerPresentationStyle, Presentation style of the Koji app.

.receiptType

'buyer' | 'seller', Type of receipt.

Interfaces

EditorAttributes

Describes the editor that the creator is using.

Properties

  • mode - 'edit' | 'new' (Optional), Distinguishes between creating a `new` customized version of the app and doing an `edit` of the user’s existing Koji app.

  • type - 'instant' | 'full' (Optional), Type of editor the creator is using, either `instant` for the Koji player or `full` for the Koji code editor.

Type aliases

BlurCallback:() => void

Function to handle when the Koji app loses focus. Invoked by the [[onBlur]] listener.

EditorMode

Distinguishes between creating a `new` customized version of the app and doing an `edit` of the user’s existing Koji app.

Possible values

  • 'edit'
  • 'new'

EditorType

Type of editor the creator is using, either `instant` for the Koji player or `full` for the Koji code editor.

Possible values

  • 'instant'
  • 'full'

FocusCallback:() => void

Function to handle when the Koji app gets focus. Invoked by the [[onFocus]] listener.

IsRemixingCallback:(isRemixing, editorAttributes) => void

Function to handle changes in the customization mode. Invoked by the [[subscribe]] listener.

Parameters

  • isRemixing - Boolean, Indicates whether the app is in customization mode.

  • editorAttributes - EditorAttributes, Describes the editor that the creator is using.

PlayerPresentationStyle

Presentation style of the Koji app, either in a modal window (`popover`) or the standard player (`fullscreen`). The player chrome (including the user's profile icon) is hidden by default when the app's `presentationStyle` is `popover`.

Possible values

  • 'fullscreen'
  • 'popover'

PlayerStateContext

Context in which the Koji app is being viewed. A Koji app can provide a distinct experience for each context.

Possible values

  • 'remix'
  • 'receipt'
  • 'screenshot'
  • 'default'

PlayerStateReceiptType

View of the receipt for a transaction, either `buyer` or `seller`.

Possible values

  • 'buyer'
  • 'seller'

ReceiptType

Who is viewing the receipt for a transaction, either `buyer` or `seller`.

Possible values

  • 'seller'
  • 'buyer'