update method
On disconnect, writes each entry of values below the location, leaving other children alone. Keys
may be multi-segment paths ('a/b'). A key that names the location itself ('', '/' or any
string of only slashes) throws an ArgumentError that names the key, and nothing is
registered; use set to replace the location on disconnect, or remove to delete it.
An empty values map registers nothing and completes the Future in a microtask, with no
request.
Keys that create a node and set its priority separately ({'x/v': 1, 'x/.priority': 3} with
x missing) complete the Future, and the server writes nothing on disconnect (measured on
production and the emulator). Write the node as one object instead,
{'x': {'v': 1, '.priority': 3}}.
Implementation
Future<void> update(Map<String, Object?> values) {
const String fnName = 'OnDisconnect.update';
final Path path = reference.spec.path;
validateWritablePath(fnName, path);
validateUserMerge(fnName, values, path);
final Map<String, Object?> normalized =
normalizeUserValue(values)! as Map<String, Object?>;
final Map<Path, Node> children = <Path, Node>{
for (final MapEntry<String, Object?> entry in normalized.entries)
Path(entry.key): nodeFromJson(entry.value),
};
return reference.database.write(
(Repo repo, WriteCompletion done) =>
repo.onDisconnectUpdate(path, children, normalized, onComplete: done),
);
}