How to broadcast and handling custom event in nativescript?



I want to create a custom event and use this event


Guys the documentation has everything you need and it has a embedded Google Search too, make use of them.


I tried but didnt got the sollution. Can you give me the sample code


For example, lets assume you want to fire a custom event on one of your StackLayout


<StackLayout id="stackLayout" class="home-panel">


    var target = page.getViewById('stackLayout');
    target.on('myCustomEvent', onMyCustomEvent);
        eventName: 'myCustomEvent',
        object: target

function onMyCustomEvent(args) {
    alert('My custom eventaaa works!!!');