Skip to content

L‐Object state

Damiano Di Vincenzo edited this page Apr 17, 2024 · 1 revision

Summary

Intro

How to read

How to write

Warnings


Intro

A space where the user can store informations for their operations/views/events.

Example: The Validation viewpoint uses it to store validation messages. This is an advanced feature, understanding the LDP system (L-object, D-object, Pointers) is a prerequisite to correctly use the state.

How to read

Can be accessed as "object.state.variablename"

When you try to access a pointer value in a root property, or inside an array at root level, it will be automatically resolved to the current object in proxy format.

How to write

Must be set as "object.state = {variablename: val}"

To delete a single variable use "object.state = {variablename: undefined}"

Yo delete the whole state use "dobject.state = undefined"

If you set dobjects as values in a root properties, or inside an array at root level, they will be stored as pointers (object.id).

Warnings

  • IMPORTANT! do not store lobjects (proxies) anywhere in the state.

    they are not serializable and might ruin your savefile, set them by id (lobj.id) or in their d-version (lobj.__raw)

  • cannot be set as "object.state.variablename = val" because only root-level properties of a proxy are safe to be assigned.

    This is a limitation due to the combination of the jodel engine and Redux's rule to not edit the state directly, see also: LDP.

  • if you retrieve values from everywhere other than at root properties or root-level arrays in the state:

    • pointers will not be resolved automatically, but can be manually resolved with L.from(pointer) or D.from(pointer)
    • dobjects will always remain at the state when they were stored and will not update their values.

    Once again this is a LDP limitation.

Clone this wiki locally