in this demo the global variable msto_prx is the root of the database.
we will use the global variable msto because it is a little nicer (has shortcuts to the parts you have exclusive write permissions to).
open devtools on two pages connected to the same database to begin
to get a copy of the datastructure without the Proxies:
jc(msto)
set values
msto.key = "value"
msto.example = {
str:"these are supported data types",
number:12.7,
bool:true,
arr:["val0",1,{z:1},["a","b"]],
obj:{d:"there is a max depth of 15"},
str2:"null isn't fully supported yet and can break things",
}
you can paste this shorter statement to avoid newlines in your devtools history :)
msto.example={str:"str_val",bool:true,number:12.7,arr:["val0",1,{z:2},["a","b"]],obj:{d:"depth 2?"},str2:"another string"}
get values
msto.example.arr[0]
// "val0"
msto.example.arr[2]
// {z:2}
the datastructure should have syncronized msto & msto_prx on both webpages
values can be strings, numbers, booleans, objects or arrays
null and undefined are not supported yet
local changes are immediate
and deletes are local only (for now)
after a value is set is pushed to everyone else who is connected
msto.ws_channels and msto.participants are write protected
msto.my_data links to the path you have write access to as does msto.my_channel
participants and channels write only data are automatically deleted after they leave
the data is not persistent it exists in the webpages of those connected
if everyone leaves a room the datastructure is destroyed