listen<T> method

Stream<FeathersJsEventData<T>> listen<T>(
  1. Function fromJson
)

Listen to On ` updated | patched | created | removed ` serviceName

If no error is occured, you will get FeathersJsEventData

Then to retrieve the data send by feathers, do: feathersJsEventData.data

Event type send by feathers: feathersJsEventData.type

Note: T is class that represent what feather js will send. You have to define it in your code

Otherwise, an exception of type FeatherJsError will be raised that can be caught on the stream

Use FeatherJsErrorType.{ERROR} to known what happen

Implementation

Stream<FeathersJsEventData<T>> listen<T>(Function fromJson) {
  if (this.client == 'socketio') {
    return this.standaloneSocketio!.listen(fromJson);
  }
  throw new FeatherJsError(
      type: FeatherJsErrorType.CONFIGURATION_ERROR,
      error: "Event listening is only available for socketio client.");
}