Building Apps with Jigx

Best practice

9min

When to use solution state (global state)

State manages the state of the app, including the UI's data and the user's interactions, and is best used in scenarios with a one-to-one relationship; for example, a field services person selects one job or task to complete, or a pilot selects one mission to fly.

Design Pattern: Singletons

Document image


Setup:

  1. Set the ID to be stored in the solution state, using the set-state action. The ID is the least amount of data required to identify each job uniquely. The ID is used throughout the solution to reference the necessary data in each of the solution's s.
  2. In the datasource queries use the ID to return the required data.
    • In a global datasource query reference the data required. The global datasource is referenced in each where the data is required.
    • In the individual 's datasource query. The query is configured to only return the exact data required for that using the ID as the unique identifier.
set-solution-state (action)
use-solution-state (datasource)


State resources and code samples:

When to use inputs

Inputs are used in complex apps to pass multiple variables between s using parameters, and is best used in scenarios where there is a one-to-many relationship, for example, a manager needs to check on the progress of each field service worker.

Design Pattern: Mediator

Document image


Setup:

  1. Set up parameters in the that needs to pass data, then in the needing to receive the data set up inputs. Multiple parameters and inputs can be configured on a single .
  2. In the components of the use expressions to reference the data passed in, for example, [email protected].
set-parameters
use-input


Input resources and code samples:

When to use outputs

Outputs are used to combine multiple s into one . Outputs pass variables from each into the next , and is best used in scenarios where there is a many-to-one relationship, for example, a manager needs to report on the progress of the team. Creating a master detail form is another usecase for outputs.

Design Pattern: Observer

Document image


Setup:

  1. In the that will pass the data define the output property with an expression that will pass the variable, such as an ID.
  2. In the composite , which combines multiple s, define the input property on the that must receive the variable.
team-progress (output)
team
team-report (input)


Output resources and code samples:

Performance optimization

Using an id in your datasource enhances performance, particularly when handling large volumes of records.

datasource