SetContext

Here you’ll find a definition for SetContext and its attributes details

What is it?

The SetContext action is responsible for changing the value of a context.

The setContext structure is:

AttributeTypeRequiredDefinition
contextIdStringContext identifier
valueAnyNew value to apply in the context
pathStringSpecific context point for changing value in case of arrays and maps <key, value>.

How to use it?

See below an example of a text that is set by context and have an initial value “Set Context Example”. The click event have a SetContext action that change the context value to “Context has changed”.

Container(
    children = listOf(
        Text(text = "@{myContext}"),
        Button(
             text = "Change context",
             onPress = listOf(
                  SetContext(
                       contextId = "myContext",
                       value = "Context has changed"
                  )
             )
        )
     ),
     context = ContextData(
          id = "myContext",
          value = "Set Context Example"
     )
)

Last modified February 11, 2021: create content (#298) (43225e15)