Giter VIP home page Giter VIP logo

comms's People

Contributors

albert221 avatar bartekpacia avatar lewandowski-jan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

comms's Issues

Export `package:comms`

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

Write tests, add coverage report to the CI

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 StateSender mixin

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);
  }

Make it possible to buffer events if no `Listener`s are registered

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:

  • do we want to make buffering optional?
  • do we want to limit the buffer size? What happens if the buffer size is exceeded?
  • are the buffered messages delivered sequentially when the listener becomes available?

cc: @iasiu

Remove `Listener2` mixin

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.

`MessageListener` loses message type in state

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

Don't depend on Flutter

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:

  • make comms a pure-Dart package
  • make comms_flutter which depends on comms and has Flutter stuff in it

cc: @iasiu

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.