Pass data to modal canDismiss on role gesture

Hey all!
I would like to pass data to canDismiss when role is ‘gesture’. I need to check if data is saved in modal. If so, canDismiss returns true else an alert should appear to inform user that the data is not saved when modal closes in this state.

Or did anybody know how to solve my problem in another way, when there is no data passing on this role?

Thanks a lot!

canDismiss: (data?: any, role?: string) => {
console.log(data); // undefined when role == ‘gesture’
console.log(role);
console.log('changed: ’ + data?.changed);
console.log('saved: ’ + data?.saved);
return new Promise(resolve => resolve(data && (!data.changed || (data.changed && data.saved))))
},