Skip to content

storage.write

since 1.1.0

Write a value to the current storage.

storage.write(label, value)

Parameters

Name Type Required Description
label string yes
value any yes the value to write

Returns

Nothing.

Examples

local function write(widget)
  storage.write("v", 2)                     -- settings version, for future migrations
  storage.write("source", widget.source)
  storage.write("threshold", widget.threshold)
end

Keep the keys and order in step with your read callback.

Used in

Real-world usage

Called 16 times across 3 open-source Ethos Lua projects. A few short excerpts:
storage.write("pumpSource", widget.pumpSource)

lua/frsky/JetWidget/main.lua:394

function widget.write() storage.write("currentPage", tostring(currentPage or 1)) end

src/inav-dashboard/widget.lua:421

local function write(widget)
    storage.write("discIdx",    widget.discIdx)
    storage.write("certIdx",    widget.certIdx)
    storage.write("trigSwitch", widget.trigSwitch)
    storage.write("rstSwitch",  widget.rstSwitch)
    storage.write("repSwitch",  widget.repSwitch)
end

src/bmfa-caller/widget_impl.lua:161