emit method

int emit(
  1. String feedId,
  2. Map<String, Object?> payload, {
  3. String? rid,
  4. Map<String, Object?>? details,
})

Reports one event on feedId, and returns the event's id.

Keep that id if the feed has item actions: an item action is invoked with event: <id> and nothing else, so the id is the only thing tying the row the user clicked back to whatever the plugin was reporting on. Discovered by the first plugin to declare one — before this returned anything, an itemAction handler had no way to know which of its own objects it had been called about.

Refuses an undeclared feed rather than dropping the event on a channel nothing renders — an undeclared feed is a typo, and a silent one costs an afternoon.

Implementation

int emit(
  String feedId,
  Map<String, Object?> payload, {
  String? rid,
  Map<String, Object?>? details,
}) {
  if (!_feeds.containsKey(feedId)) {
    throw ArgumentError(
      'panel $id has no feed "$feedId". Declared: ${_feeds.keys.toList()}',
    );
  }
  return _core.addEvent(
    panelFeedChannel(id, feedId),
    payload,
    rid: rid,
    details: details,
  );
}