Skip to main content

How logic works

Logic is everything your app does besides looking good: reacting to a tap, remembering a value, choosing what to show, loading data from the internet. In Nowa you build it visually, by picking steps from menus instead of typing code, and Nowa writes the code for you.

You don't need any programming background. The ideas on this page are the same ones every app uses, explained in everyday terms.

How the pieces fit​

  1. An event starts it. A tap, a long press or a typed letter fires an event.
  2. A function holds the steps. You stack the steps in Circuit, and they run from top to bottom.
  3. Steps use data. They read and change values stored in variables, params and global states.
  4. Widgets show the result. A property linked to a value shows it, and an expression can turn it into a calculation or a choice.

For example, picture the + button next to a product's quantity in a shop app. Its On Pressed event runs a function that adds one to a quantity variable and refreshes the screen. A text widget linked to quantity shows the new number.

The pieces​

IdeaIn plain wordsLearn more
EventSomething that happens, such as a tap, a long press or typing. It starts your logic.Respond to taps and other events
FunctionA named list of steps you can run from many places, like a recipe.Create functions
CircuitThe visual editor where you stack the steps of a function.Build logic in Circuit
VariableA value a screen or component remembers while it's open, such as the number of items in a cart.Store data in variables
ParamA value handed to a screen or component from outside, such as the product a details screen shows.Pass data with parameters
Global stateValues and functions the whole app shares, such as a cart.Share data across your app
Condition (If)A yes-or-no question that decides which steps run, such as "Is the cart empty?"Branch with If
Error handling (Try)A backup plan for steps that can fail, such as loading data without an internet connection.Handle errors with Try
ModelA custom type that groups related values, such as a Product with a name and a price.Data models
ExpressionA formula that gives a value: a link, a calculation or a condition.Expressions and conditions
ActionA ready-made step, such as showing a message or opening a link.Show dialogs, sheets, snackbars and pickers, Navigate between screens, Use ready-made actions
RouteThe path that opens a screen, such as /recipe/:id. The Router panel lists them all.Set up routes in the Router panel

Which one do I need?​

Most logic questions come down to a few choices:

You want to...Use
Remember a value on one screen, such as a counter or what someone typedA variable
Hand a value to a screen or component, such as the product to showA param
Share a value between screens, such as a cart or the signed-in userA global state
Run the same steps from several placesA function
Do one thing or another, depending on a valueAn If
Cope with a step that can fail, such as an internet requestA Try
Keep a small value after the app closes, such as a chosen languageShared Preferences

Not sure? Start with a variable on the screen that needs it, and move it to a global state once a second screen needs it too. Data and state tips goes deeper.

Everything you build turns into real app code that you own. You never have to read it, but code mode shows it whenever you're curious.

Or ask Nowa AI

Switch to Agent mode and describe what should happen: "When the user taps Add to cart, add the product to the cart and show a message." Design mode builds the look and flow without logic. Then open what it built in Circuit to check or change it. See Design, Plan and Agent modes.

Where to start​

  1. Respond to taps and other events: make a button show a message.
  2. Store data in variables: make your screen remember and show a value.
  3. Build logic in Circuit, then make decisions, handle errors and repeat steps with If, Try and loops.
  4. Navigate between screens: send people to another screen.

Next steps​