bot_storage

Creator: coderz1093

Last updated:

0 purchases

bot_storage Image
bot_storage Images

Languages

Categories

Add to Cart

Description:

bot storage

🤖 Bot Storage #

A useful package provide an interface to handle read, write and delete operations in reactive way.
Usage #
Add a dependency in your pubspec.yaml:
dependencies:
bot_storage: ^1.0.1
copied to clipboard
Simple usage using BotMemoryStorage:
import 'package:bot_storage/bot_storage.dart';

void main() {
final botStorage = BotStorageImpl();
botStorage.stream.listen(print);
await botStorage.write('new value');
await botStorage.delete();
botStorage.close();
}

class BotStorageImpl extends BotMemoryStorage<String> {
@override
String? get initValue => 'init value';
}
copied to clipboard
Or implement BotStorage with SharedPreference (or any other local storage) like this:
class BotStorageImpl extends BotStorage<String> with BotStorageMixin<String> {
BotStorageImpl(this._storage);

final SharedPreference _storage;

@override
FutureOr<void> delete() async {
super.delete();
return _storage.remove();
}

@override
String? read() {
return _storage.getString();
}

@override
FutureOr<void> write(String? value) async {
super.write(value);
_storage.setString(value);
}
}

void main() async {
final botStorage = BotStorageImpl();
botStorage.stream.listen(print);
await botStorage.write('event');
await botStorage.delete();
botStorage.close();

}
copied to clipboard
You can use BotStorageWrapper concrete class
void main(){
final BotStorageWrapper botStorageWrapper = BotStorageWrapper<String>(
delete: () {
// delete from your storage
},
read: () {
// read from your storage
return 'none';
},
write: (value) {
// write to your storage
},
);
botStorageWrapper.stream.listen(print);
botStorageWrapper.write('new value');
botStorageWrapper.delete();
botStorageWrapper.close();
}

copied to clipboard

License

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.