encodeStateAsUpdate method

Result<Uint8List, Error> encodeStateAsUpdate({
  1. required YDoc ref,
  2. Uint8List? vector,
})

Implementation

Result<Uint8List, Error> encodeStateAsUpdate({
  required YDoc ref,
  Uint8List? vector,
}) {
  final results = _encodeStateAsUpdate([
    ref.toWasm(),
    (vector == null
        ? const None().toWasm()
        : Option.fromValue(vector).toWasm()),
  ]);
  final result = results[0];
  return Result.fromJson(
    result,
    (ok) => (ok is Uint8List ? ok : Uint8List.fromList((ok! as List).cast())),
    (error) => error is String ? error : (error! as ParsedString).value,
  );
}