Client Data Store
A Client Data Store holds values in the End user’s browser that all Screens of the app can share, such as a selected filter or a shopping cart. You reach its values through the global app object as app.<storeName>.<propertyName>, not through This..
Availability: Client
How to reach it
Section titled “How to reach it”| Access path | What it is |
|---|---|
app.<storeName> | The Client Data Store’s values. <storeName> is the Client Data Store’s “name on global store”. If that is empty, it is the Client Data Store’s name with its first letter in lower case, so ShoppingCart becomes app.shoppingCart. |
app.<storeName>.<propertyName> | One value, which you can read and assign. |
This.$AppState | The type of app. |
This.<ClientDataStoreName> does not exist, and Client Data Stores are not grouped under a $ namespace either: app is the only way to reach them.
app exists in Screen code: actions, computations, the initial values of Screen variables, and the Screen’s template. Client methods outside Screens, such as clientOnly Entity methods, can’t use it.
Note
app is declared for all client-side code, so using it in a client method outside a Screen type-checks, but fails at runtime because app is not defined there.
Properties
Section titled “Properties”declare const app: This.$AppStateThe object that holds every Client Data Store as a read-only property named after its “name on global store”.
Type: This.$AppState · Availability: Client
<propertyName>
Section titled “<propertyName>”<propertyName>: <type>One value of the Client Data Store, typed as defined in the Client Data Store. Assigning a value updates every Screen that shows it.
app.shoppingCart.itemCount = app.shoppingCart.itemCount + 1Each property starts as undefined. Right after the code has loaded, Lowgile assigns the property’s default value. The values live in the browser’s memory only: reloading the page resets them.
Type: the property’s type · Availability: Client
$AppState
Section titled “$AppState”interface $AppState { readonly <storeName>: { <propertyName>: <type> }}The type of app, with one field per Client Data Store of the Module. Declared in client-side code and in calculation code; only client-side code has the app object itself.
Availability: Client
Related
Section titled “Related”- Client Data Store
- Server Data Store API
- Screen variables