addCustomValue method

void addCustomValue(
  1. String key,
  2. dynamic valueSerializer(
    1. String
    )
)

add a custom valueSerializer to a given option key. The valueSerializer is passed a serializerr type. According to that type the serializer should respond with a correct serialized value. Example:

options.addCustomValue(
 'key1', (serializerType) {
   if (serializerType == SubscribeOptions.CUSTOM_SERIALIZER_JSON) {
     return '12';
   } else if (serializerType == SubscribeOptions.CUSTOM_SERIALIZER_MSGPACK) {
     return 12;
   } else throw Exception('Unknown serializer');
 }
)
options.addCustomValue(
 'key2', (serializerType) {
   if (serializerType == SubscribeOptions.CUSTOM_SERIALIZER_JSON) {
     return '{"complexObjectKey":"complexObjectValue"}';
   } else if (serializerType == SubscribeOptions.CUSTOM_SERIALIZER_MSGPACK) {
     return {"complexObjectKey":"complexObjectValue"};
   } else throw Exception('Unknown serializer');
 }
)

Implementation

void addCustomValue(String key, dynamic Function(String) valueSerializer) {
  _customSerializedOptions[key] = valueSerializer;
}