Use Blocks to reuse parts of UI across your apps. With Blocks you can have part of the UI in one place, so changes to the Blocks are automatically visible in all Screens that use it.
Here are notes about reusing Block across different apps:
- Blocks must be public.
- You can reuse Reactive Web Blocks in Reactive Web Apps and Mobile Apps.
- You can reuse Traditional Web Blocks in Traditional Web Apps.
- In a UI Flow, add a Block (in Reactive Web and Mobile Apps) or a Web Block (in Traditional Web Apps).
- Implement the user interface and logic in the new Block.
- Set the Block as public if you want to reuse it across apps.
- Drag it the Block to the Screen where you want to use it. If you want to use the Block in another App, you first need to reference the Block.
Here is an example, with two sample apps, of how you can reuse a Block from Reactive Web App in a Mobile App.
Create MyReactiveApp and a public Block in it:
- Create a new Reactive Web App, and add a default Module to it.
- In the Module, go to Interface > UI Flows > right-click MainFlow > select Add Block. Name the Block MyBlock.
- Set the Public property of Block to Yes.
Add some content to the Block. In our example we dragged a Text Widget and entered sample text "Hello from My Reactive App!".
Publish the app.
Reuse the Block in MyPhoneApp:
- Create a new Mobile App and add a default Module to it.
- Add a Screen to the app.
- Open Manage Dependencies (CTRL+Q) and search producers for our app "MyReactiveApp". Select the app.
In left pane navigate to UI Flows > Main Flow > select MyBlock. Click Apply to confirm and close.
In the Mobile App, navigate to Interface > MyReactiveApp (name of our example app) > MainFlow2 > MyBlock.
Drag MyBlock to the Screen. You should see "Hello from My Reactive App!" in the preview.
Publish the app.