From 349916e5048d82d87898372a74dfe0b7163d43f7 Mon Sep 17 00:00:00 2001 From: shmyga Date: Mon, 13 May 2019 22:35:46 +0300 Subject: [PATCH] [storage] add delete method --- src/main/haxework/storage/IStorage.hx | 2 ++ src/main/haxework/storage/NoStorage.hx | 2 ++ src/main/haxework/storage/SharedObjectStorage.hx | 7 +++++++ 3 files changed, 11 insertions(+) diff --git a/src/main/haxework/storage/IStorage.hx b/src/main/haxework/storage/IStorage.hx index 0655c8c..bddc8aa 100755 --- a/src/main/haxework/storage/IStorage.hx +++ b/src/main/haxework/storage/IStorage.hx @@ -7,5 +7,7 @@ interface IStorage { public function read(key:String):Null; + public function delete(key:String):Void; + public function clear():Void; } diff --git a/src/main/haxework/storage/NoStorage.hx b/src/main/haxework/storage/NoStorage.hx index 3d1ccb5..3856623 100755 --- a/src/main/haxework/storage/NoStorage.hx +++ b/src/main/haxework/storage/NoStorage.hx @@ -13,4 +13,6 @@ class NoStorage implements IStorage { } public function clear():Void {} + + public function delete(key:String):Void {} } diff --git a/src/main/haxework/storage/SharedObjectStorage.hx b/src/main/haxework/storage/SharedObjectStorage.hx index c626e52..9994e5f 100755 --- a/src/main/haxework/storage/SharedObjectStorage.hx +++ b/src/main/haxework/storage/SharedObjectStorage.hx @@ -30,6 +30,13 @@ class SharedObjectStorage implements IStorage { } } + public function delete(key:String):Void { + if (exists(key)) { + Reflect.deleteField(so.data, key); + so.flush(); + } + } + public function clear():Void { so.clear(); }