import { StoreStack } from "https://deno.land/x/fresh_store@v1.0.1/mod.ts";
A multi Store container.
Methods
addStoreAtPointer(): void
Adds a store to the specified Pointer. If a store already exists at the address, an option can be passed to override it.
If override
is set to false
, but the verbose
option is set to true, and the memory is already allocated, the store will NOT
be overrided, and an error message will output to the console.
Returns a reference to the store at the address if it exists, otherwise undefined. A type can be passed in order to make the return typed.
Example
const ptr = useStore(0);
console.log(Stores.get<number>(ptr).state); // Output: 0
removeStore(ptr: Pointer, options?: { verbose?: boolean; }): void
Removes a store from the memory stack. If the Pointer's address is unallocated,
it will output an error message to the console
if verbose
option is set to true.
Static Methods
configure(): void
Checks if the StoreStack
is instantiated on window.stores
and creates it if it's not.