Expressions - Common Patterns

State Access

[email protected]         # Global app state
[email protected]               # Screen state
[email protected]   # Component value
[email protected]              # Current list item
[email protected]          # Navigation parameters
[email protected][0].name  # Datasource data
[email protected][@ctx.user.id]   # Dynamic bracket notation

Safe Defaults

[email protected] ?: @ctx.user.email ?: 'Unknown'  # Elvis - falsy fallback
[email protected] ?? 'N/A'                      # Null coalesce
[email protected] ~> $type = 'number'               # Type guard
[email protected] ? 'valid' : 'invalid'

Actions Context

[email protected]    # Action status
[email protected]     # Action result
[email protected]        # Action value
[email protected]  # Action outputs

Function Context (REST/SQL/SOAP)

[email protected]                         # Function response
[email protected]                  # HTTP status  
[email protected][0].id        # Response data
[email protected]['Content-Type'] # Headers
[email protected]       # Function params

Functions

Built-in Functions

# String
$uppercase("hello")         # "HELLO"
$lowercase("WORLD")         # "world" 
$substring("hello", 1, 3)   # "ell" 
$length("hello")            # 5
$trim("  spaces  ")         # "spaces"
$contains("hello", "ell")   # true
[email protected] & ' ' & @ctx.current.item.last

# Array  
$count(array)               # Length
$sum(numbers)               # Sum
$max(numbers) $min(numbers) # Min/max
$distinct(array)            # Unique values
$sort(array)                # Sort array
$reverse(array)             # Reverse order
$in(value, array)           # Check if value exists in array
=$filter(arr, function($v){ $v.active })
=$map(arr, function($v){ {'id':$v.id, 'name':$v.name} })

# Date/Time
$now()                      # Current timestamp
$toMillis('2025-01-01')     # To milliseconds
$formatDateTime($now(), '[Y0001]-[M01]-[D01]') // 1972-05-27

Data Filtering

Filtering & Conditionals

# Predicate filtering
[email protected][status = 'active']
[email protected][price >= 10 and price < 50]
=$filter(@ctx.datasources.items, function($v) {
  $v.category = 'electronics' and $v.inStock and $v.price < 100
})

# Conditionals
[email protected] ? 'Online' : 'Offline'
=(@ctx.jig.state.type = 'premium') ? 'Premium' : 'Standard'

# Objects
={'userId': @ctx.user.id, 'timestamp': $now(), 'data': @ctx.jig.state.selected}

Validation

# Required field
=$length(@ctx.components.email.state.value ?: '') > 0

# Email validation
[email protected] ~> /.+@.+\..+/

# Number range
=(@ctx.components.age.state.value ~> $type = 'number') and 
 @ctx.components.age.state.value >= 18 and @ctx.components.age.state.value <= 100

# Form validity
[email protected]

Last updated

Was this helpful?