Skip to content

Regrip API / session/smartCubeSession / createSmartCubeSession

Function: createSmartCubeSession()

createSmartCubeSession(options): object

Defined in: packages/core/src/session/smartCubeSession.ts:159

Create a connection-safe smart-cube session and derived-event pipeline.

Parameters

options

SmartCubeSessionOptions

Returns

connect

connect: () => Promise<void>

Returns

Promise<void>

disconnect

disconnect: () => Promise<void>

Returns

Promise<void>

getState

getState: () => SmartCubeSessionState

Returns

SmartCubeSessionState

resetGyro

resetGyro: () => void

Returns

void

sendCommand

sendCommand: (command) => Promise<void>

Parameters

command

SmartCubeCommand

Returns

Promise<void>

sendVendorCommand

sendVendorCommand: (command) => Promise<void>

Parameters

command

SmartCubeVendorCommand

Returns

Promise<void>

syncFacelets

syncFacelets: () => Promise<SmartCubeFaceletsEvent>

Request an authoritative snapshot and resolve only when it arrives.

Returns

Promise<SmartCubeFaceletsEvent>

configureFeatures()

configureFeatures(patch): void

Apply a runtime feature patch and reset any detector state it affects. Accumulates across calls and keeps applying on top of whichever profile is current, including one resolved later (e.g. after a HARDWARE event or a reconnect to a different device).

Parameters

patch

SessionFeaturesPatch

Returns

void

on()

on<T>(type, listener): () => void

Observe one event type without creating a parallel event channel.

Type Parameters

T

T extends "MOVE" | "FACELETS" | "GYRO" | "BATTERY" | "HARDWARE" | "DISCONNECT" | "REGRIP" | "CUSTOM_TRIGGER" | "SHAKE" | "MOVE_GAP"

Parameters

type

T

listener

(event) => void

Returns

() => void

subscribe()

subscribe(listener): () => void

Parameters

listener

(next) => void

Returns

() => void

subscribeDiagnostics()

subscribeDiagnostics(listener): () => void

Observe raw transport diagnostics without admitting them to the typed cube-state stream. A transport may omit this capability entirely.

Parameters

listener

(event) => void

Returns

() => void

subscribeEvents()

subscribeEvents(listener): () => void

Events remain owned by the session; consumers only observe them here.

Parameters

listener

(event) => void

Returns

() => void