from<K, V> static method

FutureOr<SharedMap<K, V>> from<K, V>({
  1. SharedMapReference? reference,
  2. String? id,
  3. SharedStoreReference? sharedStoreReference,
  4. SharedStore? sharedStore,
  5. String? sharedStoreID,
  6. SharedMapEventCallback? onInitialize,
  7. SharedMapKeyCallback<K, V>? onAbsent,
  8. SharedMapEntryCallback<K, V>? onPut,
  9. SharedMapEntryCallback<K, V>? onRemove,
})

Creates a SharedMap from reference or id.

Implementation

static FutureOr<SharedMap<K, V>> from<K, V>(
    {SharedMapReference? reference,
    String? id,
    SharedStoreReference? sharedStoreReference,
    SharedStore? sharedStore,
    String? sharedStoreID,
    SharedMapEventCallback? onInitialize,
    SharedMapKeyCallback<K, V>? onAbsent,
    SharedMapEntryCallback<K, V>? onPut,
    SharedMapEntryCallback<K, V>? onRemove}) {
  if (reference != null) {
    return SharedMap.fromSharedReference(reference)
      ..setCallbacks(
          onInitialize: onInitialize,
          onAbsent: onAbsent,
          onPut: onPut,
          onRemove: onRemove);
  }

  if (id != null) {
    sharedStore ??=
        SharedStore.from(reference: sharedStoreReference, id: sharedStoreID);
    return SharedMap.fromID(sharedStore, id,
        onInitialize: onInitialize,
        onAbsent: onAbsent,
        onPut: onPut,
        onRemove: onRemove);
  }

  throw MultiNullArguments(['reference', 'id']);
}