Use case
Hello, I love how pigeon deals with the complexity of native channels, however, due to my unfamiliarity with the topic I made a mistake of calling the generated method for creating an EventChannel stream, thus breaking platform communication with previous instances. I understand that this might be a problem that some Plugin code must deal with, but this also seems a pretty general problem. So, consider generating code that will ensure only one instance of the EventChannel exists. I am currently using this pattern that I found in a plugin that I use:
https://github.com/llfbandit/app_links/blob/e99efa708dde9886e0982d9b53b7b6b05e807c31/app_links/lib/src/app_links.dart#L52-L86
Here a StreamController is used that encapsulates the EventChannel stream and makes sure only one exists and also closing it when no subscribers are left.
Proposal
I propose that the class that is annotated with @EventChannelApi() is used as the singleton class name and that methods or getters in this class create the needed StreamControllers.
Use case
Hello, I love how pigeon deals with the complexity of native channels, however, due to my unfamiliarity with the topic I made a mistake of calling the generated method for creating an EventChannel stream, thus breaking platform communication with previous instances. I understand that this might be a problem that some Plugin code must deal with, but this also seems a pretty general problem. So, consider generating code that will ensure only one instance of the EventChannel exists. I am currently using this pattern that I found in a plugin that I use:
https://github.com/llfbandit/app_links/blob/e99efa708dde9886e0982d9b53b7b6b05e807c31/app_links/lib/src/app_links.dart#L52-L86
Here a StreamController is used that encapsulates the EventChannel stream and makes sure only one exists and also closing it when no subscribers are left.
Proposal
I propose that the class that is annotated with
@EventChannelApi()is used as the singleton class name and that methods or getters in this class create the needed StreamControllers.