programSubscribe method

Stream programSubscribe(
  1. String programId, {
  2. Encoding encoding = Encoding.jsonParsed,
  3. List<ProgramFilter>? filters,
  4. Commitment? commitment,
})

Subscribe to a program to receive notifications when the lamports or data for a given account owned by the program changes.

Returns a Stream that can be used to listen for events. By cancelling the subscription returned by the Stream.listen() method of this stream client will automatically send programUnsubscribe message;

For commitment parameter description see this document.

Commitment.processed is not supported as commitment.

Implementation

Stream<dynamic> programSubscribe(
  String programId, {
  Encoding encoding = Encoding.jsonParsed,
  List<ProgramFilter>? filters,
  Commitment? commitment,
}) =>
    _subscribe<dynamic>(
      'program',
      params: <dynamic>[
        programId,
        <String, String>{
          'encoding': encoding.value,
        },
        ...?filters,
        if (commitment != null)
          <String, String>{
            'commitment': commitment.value,
          },
      ],
    );