Last active
May 7, 2021 14:44
-
-
Save Ingco/21ee2f8958977306b83f1df4e6cde070 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class RecommendationStream { | |
RecommendationStream() { | |
... | |
_notificator.outEvent.listen((event) { | |
print('ЭТОТ ТЕКСТ ПЕЧАТАЕТ ДВАЖДЫ'); | |
if (event == ProfileScreenEvents.UPDATE_LOCAL) { | |
send(); | |
} else if (event == ProfileScreenEvents.UPDATE_REMOTE) { | |
sendNew(); | |
} | |
}); | |
} | |
... | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
onTap: () { | |
Navigator.pushNamed( | |
context, | |
SettingsScreen.routeName, | |
arguments: args, | |
).then((value) { | |
context | |
.read<MainSourceData>() | |
.notificator | |
.inEvent | |
.add(ProfileScreenEvents.UPDATE_REMOTE); | |
}); | |
}, | |
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
Navigator.pushNamedAndRemoveUntil( | |
context, | |
UserProfileScreen.routeName, | |
ModalRoute.withName(StartScreen.routeName), | |
arguments: args, | |
); | |
Timer( | |
Duration(seconds: 3), | |
() { | |
ProfileScreenNotification _notificator = ProfileScreenNotification(); | |
StreamSink<ProfileScreenEvents> profileUpdater = _notificator.inEvent; | |
profileUpdater.add(ProfileScreenEvents.UPDATE_REMOTE); | |
} | |
); | |
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'dart:async'; | |
enum ProfileScreenEvents { UPDATE_LOCAL, UPDATE_REMOTE } | |
class ProfileScreenNotification { | |
static final ProfileScreenNotification _instance = ProfileScreenNotification._(); | |
ProfileScreenNotification._(); | |
factory ProfileScreenNotification() { | |
return _instance; | |
} | |
StreamController<ProfileScreenEvents> _controller = | |
StreamController<ProfileScreenEvents>.broadcast(); | |
StreamSink<ProfileScreenEvents> get inEvent => _controller.sink; | |
Stream<ProfileScreenEvents> get outEvent => _controller.stream; | |
void dispose() { | |
_controller.close(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment