View Full Version : Sharing variables and data context between apps in v1.2

2014-08-03, 00:12
In Lianja v1.2, note that in a desktop App you can now extend the Lianja system object like this to pass data between apps. Try this from the console.

Lianja.mydata = object()
Lianja.mydata.name (http://lianja.mydata.name/) = "Barry"
declare mytable[10]
Lianja.mydata.mytable = mytable
Lianja.mydata.mytable[1] = "Lianja"
Lianja.mydata.mytable[2] = object()
Lianja.mydata.mytable[2].name = "Hello world"
? json_encode( Lianja.mydata )
? json_decode( json_encode( Lianja.mydata ) )

So in other words you can extend the Lianja system object with your own data that persists between each App that you open.

Lianja, unlike VFP reference counts the arrays and objects so they can be assigned into data structures as above.

There is some more functionality coming soon to share data across web and mobile apps but its not production ready. I will document it when it is completed to my satisfaction. This is to do with persisting data between sessions in localStorage and sessionStorage in Desktop, Web and Mobile Apps.

2014-08-07, 03:22
Hi Barry,
in this way, if I use the virtual table, I can create an app that acts as a menu .. and throw in more contemporary app?


2014-08-07, 03:26
Hi Fabio,

Sure, you can do what you want :) as long as your "contemporary app" has access to the Lianja system object.

2014-08-07, 03:31
Lasagna for Barry! :-)


2014-08-07, 03:33
In v1.2 (should be released today) you also have this that you can use in the Desktop and Web Client to maintain state between Apps.

Lianja.localStorage.setItem(key, value)


value = Lianja.localStorage.getItem(key)


Lianja.sessionStorage.setItem(key, value)


value = Lianja.sessionStorage.getItem(key)

In a point release I will "persist" the localStorage in the desktop client so that it is there next time an app runs.

You can store e JSON encoded object and use json_decode(value) to restore the state of an object.

This "persistence" is not yet in v1.2. It will be added later.