Build behaviour (Flow-Driven Development)
Reusable logic and packages
Build functions that belong to no system and call them anywhere, add logic packages, and publish your own flows and logic.
Open Logic in the appLogic that belongs to no system
Most logic belongs to a system: an API's endpoint logic, a button's event logic. Some steps are the same everywhere: normalize an email, check a password's strength, work out VAT. Write those once as reusable logic and call them from any logic in any system.
Reusable logic is always a function: it takes inputs and returns outputs. Its key starts with LOGIC-LIB-…. On the Logic page it is listed first, under Reusable logic.
When a flow runs, reusable logic runs in the system of the logic that called it. Its steps show in the caller's lane, not a lane of their own.
Create a reusable function
- Open Logic and press New logic.
- Pick Function as the kind.
- Under System, choose No system (reusable anywhere).
- Name it, list What it takes and What it gives back, and press Create and open.
A function that belongs to a system can be shared too: tick Library (reusable by any system).
You can also make one from steps you already have. Select them on the canvas, right-click and choose Turn into a function. They move into a new function, and a Call Function step takes their place.
Call it
In any logic, open Nodes and switch to Other logic (or … → Use other logic…). It lists this system's functions and the shared ones. Add one and it becomes a Call Function step, with the function's inputs and outputs as connection points.
The function's … → Where it is used lists every logic that calls it and the systems and flows it runs in, so you know what a change affects. Generated code puts reusable logic in a shared folder.
Logic packages
The Store has logic packages, each with a clear name and version number: @publisher/name with a version. Each one is a set of functions that only calculate: no API calls, database queries or events, so they run anywhere.
- Open the Store and pick the Logic tab.
- Open a package. Its examples run on the page; Try it runs it on your input.
- Press Add to my logic. The functions are copied into your organization or project as reusable logic, and the copy is recorded.
Or take only the code with Download code or Copy code.
Added logic keeps a chip that links to its package, and its Where used names the package. The Added tab lists everything you added.
Publish your own
Anyone can publish a flow or a function so the rest of the organization can use it: everyone in it finds the package in the store and can copy it into any of its projects. Other organizations don't see it.
- For a flow, press Publish on the flow page. For a function, open the logic editor's More menu and choose Publish to store….
- Write a Title, a Summary, a Description and Tags.
- Under Publish as, choose your organization (
@your-org/…) or yourself (@your-name/…). - Pick the Version. The first is
1.0.0; after that, choose a fix, a new feature or a breaking change, and say What changed. - Look at the Checks and press Publish.
Before publishing, Rabbinatix checks the package:
A new version must be higher than the latest. Your packages show on the Store's Published by you tab, where you can Unpublish them.
Versions
Adding copies a version into your organization or project. Later versions don't change your copy. See Versions and releases for how versions work elsewhere in Rabbinatix.
Related
- LogicBuild what a system does by connecting nodes on a canvas: endpoint logic for an API, event logic for a user action, and functions you reuse.
- The StoreFree, tested flows, logic, system maps and whiteboards: try one on its page, fit it to your systems, and copy it in, or take its code.
- Code generationSee the code for a logic as you build it, take it away as files, and check it returns what the test cases returned.
- Versions and releasesRun API versions side by side, read the history and diff of every endpoint, create releases with a suggested version, and check old copies.
