Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save JulianBissekkou/b9b1edc0cbfc256909b7d2e11e554c93 to your computer and use it in GitHub Desktop.
Save JulianBissekkou/b9b1edc0cbfc256909b7d2e11e554c93 to your computer and use it in GitHub Desktop.
class SubscriptionViewModelImpl implements SubscriptionViewModel {
var _mailTextController = StreamController<String>.broadcast();
@override
Sink get inputMailText => _mailTextController;
@override
Stream<bool> get outputIsButtonEnabled => _mailTextController.stream
.map((email) => EmailValidator.isEmailValid(email));
@override
Stream<String> get outputErrorText => outputIsButtonEnabled
.map((isEnabled) => isEnabled ? null : "Invalid email");
@override
void dispose() => _mailTextController.close();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment