Skip to content

Commit 57d454b

Browse files
committed
✨ update documentation for JsonItemHolder to clarify instance behavior with duplicate keys
1 parent 380e129 commit 57d454b

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

packages/hyper_storage/lib/src/item_holder.dart

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,11 @@ mixin ItemHolderMixin on BaseStorage {
297297
/// be serializable to/from JSON using the provided [toJson] and [fromJson]
298298
/// functions.
299299
///
300+
/// Note: Calling this method with the same key multiple times will return
301+
/// the same instance of [JsonItemHolder] if it already exists, ensuring that
302+
/// there is only one holder per key. If the existing holder has been closed,
303+
/// a new instance will be created.
304+
///
300305
/// Parameters:
301306
/// - [key]: The key under which to store the object. Must be non-empty and
302307
/// not only whitespace. This key is relative to the container (not
@@ -352,6 +357,11 @@ mixin ItemHolderMixin on BaseStorage {
352357
/// be serializable using the provided [serialize] and [deserialize]
353358
/// functions.
354359
///
360+
/// Note: Calling this method with the same key multiple times will return
361+
/// the same instance of [JsonItemHolder] if it already exists, ensuring that
362+
/// there is only one holder per key. If the existing holder has been closed,
363+
/// a new instance will be created.
364+
///
355365
/// Parameters:
356366
/// - [key]: The key under which to store the object. Must be non-empty and not only whitespace.
357367
/// This key is relative to the container.
@@ -400,6 +410,11 @@ mixin ItemHolderMixin on BaseStorage {
400410
/// This makes it easier to pass around a fragment of the storage (without needing to reference
401411
/// the entire storage/container) that knows how perform operations on that specific key.
402412
///
413+
/// Note: Calling this method with the same key multiple times will return
414+
/// the same instance of [JsonItemHolder] if it already exists, ensuring that
415+
/// there is only one holder per key. If the existing holder has been closed,
416+
/// a new instance will be created.
417+
///
403418
/// Type parameter [E] specifies the type of item to store. Supported types include:
404419
/// - String
405420
/// - int
@@ -478,6 +493,11 @@ mixin ItemHolderMixin on BaseStorage {
478493
/// a factory function that constructs the holder. This is useful for creating
479494
/// specialized holders that may have custom behavior or serialization logic.
480495
///
496+
/// Note: Calling this method with the same key multiple times will return
497+
/// the same instance of [JsonItemHolder] if it already exists, ensuring that
498+
/// there is only one holder per key. If the existing holder has been closed,
499+
/// a new instance will be created.
500+
///
481501
/// Parameters:
482502
/// - [key]: The key under which to store the item. Must be non-empty and not only whitespace.
483503
/// This key is relative to the container (not encoded).

0 commit comments

Comments
 (0)