LazxListener constructor

LazxListener({
  1. required LazxState data,
  2. LazxListenerBuilder? initial,
  3. LazxListenerBuilder? loading,
  4. LazxListenerBuilder? success,
  5. LazxListenerBuilder? error,
})

Implementation

LazxListener(
    {required this.data,
    this.initial,
    this.loading,
    this.success,
    this.error}) {
  /// We listen to the data's state and calling the right listener builder
  /// function
  data.state.listen((state) {
    switch (state) {
      case LxState.Initial:
        initial?.call(state);
        break;
      case LxState.Loading:
        loading?.call(state);
        break;
      case LxState.Success:
        success?.call(state);
        break;
      case LxState.Error:
        error?.call(state);
        break;
    }
  });
}