thlorenz / rid

Rust integrated Dart framework providing an easy way to build Flutter apps with Rust.
64 stars 4 forks source link

feat: adding rid message channel #27

Closed thlorenz closed 2 years ago

thlorenz commented 2 years ago

Adds a message channel built into Rid that is aside from the reply channel concerned with handling replies to user messages sent to Rust.

This message channel supports sending message from rust to dart and is built into the rid framework along with the following macros leveraging it:

The log messages can then be handled on the Dart/Flutter side to output them via print/debugPrint indicating that they come from Rust. This will make debugging rid apps much easier.

For now I'll implement an example of doing this in the next example app and will think about how/which parts can be added to rid proper to make using the message channel for logs easier.

The error messages are meant to be handled as follows:

These as well will be added to the example and I will see if an API to handle this as described can be included with Rid in the future.

rid class

With these changes I introduced a Rid class accessible via rid on the Dart side. It provides access to the rid.messageChannel and will include access to more features coming in the future. I'm also considering adding the config properties like RID_LOG_DEBUG and such to this class.