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

Custom App Events

Publish and respond to custom app events

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

Loopback has several standard events including "started" and "stopping". But you are not limited to just these events. You can create your own events as well.

Publishing a Custom Event

In an App Behavior or Business Object Behavior, you can publish an event like this:

this.app.emit('My Custom Event');

You can also send data along with the event:

this.app.emit('My Custom Event With Data', { blah: 'asdf' } );

Respond to a Custom Event

In an App Behavior or Business Object Behavior, you can respond to a custom event like this:

this.app.on('My Custom Event', async ()=>{
    debug('My Custom Event happened!');
});

If the event includes data, you can handle it like this:

this.app.on('My Custom Event', async (data:any)=>{
    debug('My Custom Event send me', data);
});

Only Within a Single Node

Remember that these events are only within a single node. If you need to manage events across multiple nodes in a cluster, you can check out the Socket Io Library.

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