Persist
const persist = require("@vectarine/persist")Functions
Section titled “Functions”persist.onReload
Section titled “persist.onReload”persist.onReload<T>(defaultValue: T, globalName: string): TGet a value that persist when the script is hot-reloaded. The value is stored as a global variable named globalName
and can be inspected in the watcher.
persist.onReloadWithProvider
Section titled “persist.onReloadWithProvider”persist.onReloadWithProvider<T>(provider: () -> T, globalName: string): TSame as onReload, but instead of taking a default value, it takes a provider function.
This is useful if the default value is expensive to create so it is not created on hot-reload.
persist.save
Section titled “persist.save”persist.save(name: string, value: any)Save value so that it is persisted across restarts.
You can obtain saved values using load.
Saving can take some time, so calling save followed by load might not give the expected result.
name can only contain letters, numbers, underscore and dot.
persist.load
Section titled “persist.load”persist.load(name: string): any?Load a saved value. If the value does not exist, return nil.
