Core · class

OnceSet

A persisted set of one-time flags: tutorial prompts, first-run hints, "you have seen this" markers.

Explained in The loop.

class OnceSet
import { OnceSet } from '@driftengine/core';

In depth

One key holding a set rather than a key per flag, because a game accumulates dozens of these and a key each turns a player's save into a junk drawer that cannot be cleared in one action.

Where it persists is the store's problem. When the store cannot keep anything, flags last the session — showing a tutorial once per visit is mildly annoying, while never showing it strands a player who arrived from a link with no idea what the controls are.

Constructor

new

constructor(key: string, store?: KeyValueStore)
ParameterTypeDescription
keystring
store?KeyValueStore

Methods

has

has(id: string): boolean
ParameterTypeDescription
idstring

claim

claim(id: string): boolean

True the first time only. Marks the flag as a side effect.

ParameterTypeDescription
idstring

mark

mark(id: string): void
ParameterTypeDescription
idstring

clear

clear(): void

Forget everything — "show me the tutorial again".