Type that represents the state
Optionalscoped: booleanOptionalcustomStorage: StateServiceOptionalcustomKey: stringDelete the state from the storage
Enter some scene
Optionalparams: { reset?: boolean; ttl?: number; with?: SceneState }Optionalreset?: booleanIf currently in a scoped scene, whether to reset the state
Optionalttl?: numberTTL for the scene (in seconds)
Optionalwith?: SceneStateInitial state for the scene
Note that this will only work if the scene uses the same key delegate as this state.
Exit from current scene to the root
Whether to reset scene state (only applicable in case this is a scoped scene)
Retrieve the state from the storage
Optionalforce: booleanWhether to ignore cached state (def. false)
Merge the given object to the current state.
Note: If the storage currently has no state, then
fallbackmust be provided.
Basically a shorthand to calling .get(),
modifying and then calling .set()
Rate limit some handler.
When the rate limit exceeds, RateLimitError is thrown.
This is a simple rate-limiting solution that uses the same key as the state. If you need something more sophisticated and/or customizable, you'll have to implement your own rate-limiter.
Note:
keyis used to prefix the local key derived using the given key delegate.
Key of the rate limit
Maximum number of requests in window
Window size in seconds
Tuple containing the number of remaining and unix time in ms when the user can try again
Reset the rate limit
Key of the rate limit
Set new state to the storage
New state
Optionalttl: numberTTL for the new state (in seconds)
Throttle some handler.
When the rate limit exceeds, this function waits for it to reset.
This is a simple wrapper over rateLimit, and follows the same logic.
Note:
keyis used to prefix the local key derived using the given key delegate.
Key of the rate limit
Maximum number of requests in window
Window size in seconds
Tuple containing the number of remaining and unix time in ms when the user can try again
State of the current update.
Template: SceneName
Possible scene names