Apex Designer Documentation
What's New
Getting Started
Business Objects
User Interfaces
App Behaviors
Project Settings
Patterns and Best Practices
App Showcase
Frequently Asked Questions

App Behaviors

Add custom endpoints and server-side event handling logic to your app.

Blank Profile Image
Written by David Knapp
Updated 2 years ago
Less than a minute read

Custom Rest Endpoint

An app behavior can be of type "Endpoint". This adds a custom REST endpoint to the application.

The Auth0 Client Configuration in the Auth0 Loopback 4 library is a good example. It adds an endpoint "/api/auth0ClientConfiguration" that is called from the client side to get the Auth0 domain and client id at runtime. This allows one app build to be used with many different Auth0 configurations.

Endpoint App Behaviors can be called from User Interface Methods using the following shortcut:  Include ApexAppService in your User Interface Dependencies, then call the behavior from your method using:

// Call endpointBehaviorName Endpoint App Behavior from a User Interface Method
await this.apexAppService.endpointBehaviorName();

Event Handler

An event handler is executed when specific events happen. The event can be a standard Loopback event or a custom event.

The Monitor Datasources behavior in the Loopback 4 Base Library is a good example of an event that happens when the app has started. It waits for the app to start and then sets an interval to check the status of the database connection pool.

The Set Up Socket Io Server behavior in the Socket Io Library is a good example of using a custom event. It waits for the "Schema Up To Date" event that is published by the Update Schema observer and then sets up the Postgres Adapter for socket.io so that realtime messaging works across nodes.

Reusable Behaviors

Reusable behaviors are functions that can be called in App Behaviors and Business Object Behaviors. A reusable behavior has parameters (inputs) and a return type (output type). By default, a reusable behavior is an async functions but you can change a reusable behavior to a synchronous function by clicking the settings icon button.

Powered by Apex Designer
Terms of ServicePrivacy Policy
© 2017-2024 Apex Process Consultants