Skip to main content

Interface: Activity

Properties​

additionalParameters?​

readonly optional additionalParameters: unknown

Additional activity parameters that were set.

Defined in​

m2c2kit/packages/core/src/Activity.ts:97


beginIso8601Timestamp​

beginIso8601Timestamp: string

The value of new Date().toISOString() immediately before the activity begins

Defined in​

m2c2kit/packages/core/src/Activity.ts:93


beginTimestamp​

beginTimestamp: number

The value of performance.now() immediately before the activity begins

Defined in​

m2c2kit/packages/core/src/Activity.ts:91


dataStores?​

optional dataStores: IDataStore[]

Optional stores to use for saving data. The implementation of the store is not provided by the @m2c2kit/core library.

Defined in​

m2c2kit/packages/core/src/Activity.ts:99


id​

id: string

Short identifier of this activity

Defined in​

m2c2kit/packages/core/src/Activity.ts:83


name​

name: string

Human-friendly name of this activity

Defined in​

m2c2kit/packages/core/src/Activity.ts:81


publishUuid​

publishUuid: string

Persistent unique identifier (UUID) of the activity. Required for games. Optional or empty string if a survey.

Defined in​

m2c2kit/packages/core/src/Activity.ts:85


sessionUuid​

sessionUuid: string

The activity's parent session unique identifier. This is newly generated each session.

Defined in​

m2c2kit/packages/core/src/Activity.ts:77


studyId?​

optional studyId: string

The ID of the study (protocol, experiment, or other aggregate) that contains the repeated administrations of this activity. The ID should be short, url-friendly, human-readable text (no spaces, special characters, or slashes), e.g., nyc-aging-cohort.

Defined in​

m2c2kit/packages/core/src/Activity.ts:87


studyUuid?​

optional studyUuid: string

Unique identifier (UUID) of the study (protocol, experiment, or other aggregate) that contains the administration of this activity.

Defined in​

m2c2kit/packages/core/src/Activity.ts:89


type​

type: ActivityType

The type of activity: Game or Survey

Defined in​

m2c2kit/packages/core/src/Activity.ts:9


uuid​

uuid: string

The activity's unique identifier. This is newly generated each session. The UUID for an activity will vary across sessions.

Defined in​

m2c2kit/packages/core/src/Activity.ts:79

Methods​

init()​

init(): Promise<void>

Initializes the activity.

Returns​

Promise<void>

Remarks​

All code to create the activity's appearance and behavior must be placed in this method. This method is asynchronous, and must be awaited. When writing a new game by extending the Game class, this method will be overridden, but the base method must still be called with await super.init().

Deprecated​

use Game.initialize() instead.

Defined in​

m2c2kit/packages/core/src/Activity.ts:31


initialize()​

initialize(): Promise<void>

Initializes the activity.

Returns​

Promise<void>

Remarks​

All code to create the activity's appearance and behavior must be placed in this method. This method is asynchronous, and must be awaited. When writing a new game by extending the Game class, this method will be overridden, but the base method must still be called with await super.initialize().

Defined in​

m2c2kit/packages/core/src/Activity.ts:19


onCancel()​

onCancel(callback, options?): void

Executes a callback when the activity is canceled.

Parameters​

• callback

function to execute.

• options?: CallbackOptions

options for the callback.

Returns​

void

Defined in​

m2c2kit/packages/core/src/Activity.ts:52


onData()​

onData(callback, options?): void

Executes a callback when the activity generates data.

Parameters​

• callback

function to execute.

• options?: CallbackOptions

options for the callback.

Returns​

void

Defined in​

m2c2kit/packages/core/src/Activity.ts:72


onEnd()​

onEnd(callback, options?): void

Executes a callback when the activity ends.

Parameters​

• callback

function to execute.

• options?: CallbackOptions

options for the callback.

Returns​

void

Defined in​

m2c2kit/packages/core/src/Activity.ts:62


onStart()​

onStart(callback, options?): void

Executes a callback when the activity starts.

Parameters​

• callback

function to execute.

• options?: CallbackOptions

options for the callback.

Returns​

void

Defined in​

m2c2kit/packages/core/src/Activity.ts:42


setParameters()​

setParameters(additionalParameters): void

Sets additional activity parameters if defaults are not sufficient.

Parameters​

• additionalParameters: unknown

Returns​

void

Defined in​

m2c2kit/packages/core/src/Activity.ts:95


start()​

start(): Promise<void>

Starts the activity

Returns​

Promise<void>

Defined in​

m2c2kit/packages/core/src/Activity.ts:33


stop()​

stop(): void

Stops the activity

Returns​

void

Defined in​

m2c2kit/packages/core/src/Activity.ts:35