leancodepl / comms Goto Github PK
View Code? Open in Web Editor NEWSimple communication pattern abstraction on streams.
License: Apache License 2.0
Simple communication pattern abstraction on streams.
License: Apache License 2.0
One common use case is a cubit that both sends and receives messages. This can be achieved by using a ListenerCubit with Sender
, but that requires importing both packages
We should allow developers to specify their own log function to MessageSinkRegister
or to turn off logging.
Add to readme example showing sending one time events between state management and ui implemented with comms pattern.
Ideally, most of the public API surface should be unit-tested.
Having code coverage report in the CI would also be great (so that after every PR we'd see whether the coverage increased or decreased).
Add example of usage.
A StateSender
would just override the emit
method and after super.emit
it'd call send
function.
This is currently achieved by overriding emit
manually and adding mixin Sender<SomeState>
:
@override
void emit(SomeState state) {
super.emit(state);
send(state);
}
Currently if we do send(SomeType())
and no Listeners<SomeType>
are registered, nothing will happen.
Today I talked with @iasiu and he suggested to make send()
buffered, i.e when the listener for some type is not available, messages are stored in some buffer. Later on, when the listener for that type becomes available, all messages are delivered at once.
To discuss:
cc: @iasiu
I hate it. If Dart doesn't allow this, let's not fight the language.
IMHO we should strive to be a small, nonbloated, pretty and cute helper lib.
Listener2
mixin was added in #34.
Add to readme example showing communication between AuthCubit
and UserProfileCubit
implemented with comms pattern.
subosito/flutter-action#183 broke our CI, but now it's fixed.
I suggest we wait for the stable release instead of using main
.
Some of bloc
related APIs from flutter_comms
could be moved to comms
:
CubitListener
BlocListener
StateSender
With the setup as below:
class MyMessage {
const MyMessage();
}
void build(BuildContext context) {
return MessageListener<MyMessage>(
onMessage: (message) {
print('Got it!');
},
child: Container(),
);
}
Upon sending the message, the listener throws an exception: Unhandled Exception: type '(MyMessage) => void' is not a subtype of type '(dynamic) => void'
. This is caused by the listener widget not fully passing the message type to the state:
class _MessageListenerState<Message> extends SingleChildState<MessageListener> with Listener<Message> { ... }
~~~~~~~~~~~~~~^^
no type parameter
Add example of usage.
Add a common README file for both packages, examples:
Update packages, sdk constraints, changelog, pubspec versions and workflows
I'd like to be able to use this package in non-Flutter project, but currently I can't because it depends on Flutter.
Scope:
comms
a pure-Dart packagecomms_flutter
which depends on comms
and has Flutter stuff in itcc: @iasiu
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.