Helper Methods
The SDK contains several helper methods which can be used for data processing purposes.
Capture an updated email
setOnEmailChange
allows you to always capture the update when the email address has been changed.
window.checkin.dataFlow.setOnEmailChange((email) => {
console.log('Email change detected', email)
})
As with the setOnUpdate
method, you can also validate the updated email address and throw an error.
window.checkin.dataFlow.setOnEmailChange((email) => {
if (email.startsWith("change")) {
return window.checkin.generate.dataError.custom({
title: "Email Change detected",
message: "Starts with change",
type: "Mock Type",
});
}
});
Capture an updated password
setOnPasswordChange
allows you to always capture the update when the password has been changed.
window.checkin.dataFlow.setOnPasswordChange((password) => {
console.log('Password change detected', password)
})
As with the setOnUpdate
method, you can also validate the updated password and throw an error.
window.checkin.dataFlow.setOnPasswordChange((password) => {
if(password === "invalidPassword") {
return window.checkin.generate.dataError.unknown();
}
if (password.startsWith("a")) {
return window.checkin.generate.dataError.custom({
title: "Password error",
message: "we dont like errors starting with a",
type: "PasswordA",
});
}
});
getEmail
This helper method can be used to get the email address entered by the user.
It will return a promise.
const email = await window.checkin.dataFlow.getEmail()
console.log(email)
getPassword
This helper method can be used to get the password entered by the user.
It will return a promise.
const password = await window.checkin.dataFlow.getPassword()
console.log(password)
getPhone
This helper method can be used to get the phone number entered by the user.
It will return a promise.
const phone = await window.checkin.dataFlow.getPhone()
console.log(phone)
Updated about 3 years ago