register<T> function

void register<T>(
  1. EJsonEncoder<T> encoder,
  2. EJsonDecoder<T> decoder, {
  3. Iterable<Type>? superTypes,
})

Register custom EJSON encoder and decoder for a type T. The last registered codec pair for a given type T will be used.

Implementation

void register<T>(EJsonEncoder<T> encoder, EJsonDecoder<T> decoder, {Iterable<Type>? superTypes}) {
  TypePlus.add<T>(superTypes: superTypes);
  customEncoders[T] = encoder;
  customDecoders[T] = decoder;
}