UNPKG

@btfuse/core

Version:

A native-first framework for building hybdrid web-native applications

59 lines (56 loc) 2.04 kB
"use strict"; /* Copyright 2023-2025 Breautek Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ Object.defineProperty(exports, "__esModule", { value: true }); exports.FuseMemoryStore = void 0; const ContentType_1 = require("../ContentType"); const FusePlugin_1 = require("../FusePlugin"); /** * A class to interface with native memory store object * These memory stores can store stateful strings. This state * is kept in memory even if the OS destroys the application's UI while * the application is in the background. * * This is not to be confused with persistent storage. The memory * store is intended to simply store state in between a paused application. * If the application completely gets closed, destroyed or stopped by the user, * the memory store will be cleared. */ class FuseMemoryStore extends FusePlugin_1.FusePlugin { constructor(context) { super(context); } _getID() { return 'FuseMemoryStore'; } /** * @param key - A name for the value * @param value - The value to store, only stringified data is permitted */ async set(key, value) { await this._exec('/set', ContentType_1.ContentType.JSON, { key: key, value: value }); } /** * @param key - The stored key * @returns */ async get(key) { let response = await this._exec('/get', ContentType_1.ContentType.TEXT, key); return await response.readAsText(); } } exports.FuseMemoryStore = FuseMemoryStore; //# sourceMappingURL=FuseMemoryStore.js.map