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 OnceSetimport { 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)| Parameter | Type | Description |
|---|---|---|
key | string | |
store? | KeyValueStore |
Methods
has
has(id: string): boolean| Parameter | Type | Description |
|---|---|---|
id | string |
claim
claim(id: string): booleanTrue the first time only. Marks the flag as a side effect.
| Parameter | Type | Description |
|---|---|---|
id | string |
mark
mark(id: string): void| Parameter | Type | Description |
|---|---|---|
id | string |
clear
clear(): voidForget everything — "show me the tutorial again".