Login Gate Handler

The Login Gate Handler was created with the aim of centralizing and simplifying the logic for adding the Login Gate for any feature.

Parameters and Callbacks

The Login Gate Handler needs some parameters and callbacks to work correctly:

  • coroutineScope: obligatory, the coroutine scope that will be used to observe the Login/Register result.
  • loginGateSettings: obligatory, the feature Login Gate Settings.
  • openLoginGate: obligatory callback, as each feature has it specific needs when opening the Login Gate, this method will call invoked when the handler judges necessary.
  • onFailure: optional callback, this method is invoked when the login gate is enabled and the user dismiss the Login or Register screens.
  • onSuccess: optional callback, this method is invoked when the login gate is enabled and the user successfully Login, Register or taps the Continue as Guest button.
  • onContinue: optional callback, this method is invoked when the login gate is disabled or the user is already Logged In.

How To Use

To use the Login Gate Handler, first it needs to be injected by the View, ViewModel, etc. After the injection it should be called this way:

loginGateHandler.handle(
coroutineScope = coroutineScope,
loginGateSettings = LoginGateSettings(
isEnabled = true,
isContinueAsGuestAvailable = false,
),
openLoginGate = {
// Method that will be invoked when is necessary to open the Login Gate.
},
onFailure = {
// Method that will be invoked when the user dismiss the Login or Register screen.
},
onSuccess = {
// Method that will be invoked when the user successfully Login, Register or Continue as Guest.
},
onContinue = {
// Method that will be invoked when the Login Gate is not necessary or the user is already Logged In.
},
)

Examples of how to use it can be found in this features: