-
-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Services integration 3 #123
base: flutter
Are you sure you want to change the base?
Services integration 3 #123
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
required Future<void> Function() inactiveFunction, | ||
required Future<void> Function() activeFunction, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: maybe name like activatedFunction / deactivatedFunction would be more intuitive (it'd suggest that they are called on event).
@override | ||
final Event<Value<String>> stateChangeEvent = Event("stateChangeEvent"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's preferably to use enums instead of string identifiers. If you change a string in one place, but forget to change it in another, you won't get a compiler error and the change will remain unnoticed.
We could introduce BackendEvent
enum and use Event<Value<BackendEvent>>
. Alternatively, we can create two separate events without values at all: senderStateChangeEvent
and receiverStateChangeEvent
.
@override | ||
bool receiverIsAlive = false; | ||
|
||
@override | ||
bool senderIsAlive = false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since receiverIsAlive/senderIsAlive values are now cached until onAnyEvents is called, it can lead to a small inconsistency: model calls startReceiver() and then reads receiverIsAlive and it can see that it's false just because event was not delivered from kotlin to dart yet.
To avoid this, we can update startReceiver/stopReceiver/startSender/stopSender so that they will update receiverIsAlive/senderIsAlive before returning.
ModelRoot(Logger logger, Backend backend) { | ||
this.receiver = Receiver(logger, backend); | ||
this.receiver.setDefultValues(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe inline setDefultValues logic into ctor? Isn't it an implementation detail?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems that we can remove setReceiverIPs() method. UI doesn't need to set write this field, only read it.
No description provided.