0.0.3 • Published 1 year ago

@boulton/disposable-types v0.0.3

Weekly downloads
-
License
MIT
Repository
-
Last release
1 year ago

@boulton/disposable-types

A shared library that exports commonly-used types related to disposable items.

See the @boulton/react-disposable-state library for more information.

What is a disposable item?

A disposable item is an item that is explicitly created. When it is created, a separate destructor (a.k.a. dispose function, cleanup function) is also created. When that destructor is called, the created item should no longer be used.

An example might be a claim to a resource in a shared store.

const [claim, disposeClaim]: ItemCleanupPair<Claim> = store.getClaimToResource({
  id: 4,
});

// Because the claim has not been disposed, this is safe to do:
const data = store.lookup(claim);

disposeClaim();

// Now that we've disposed of the claim, the underlying resource might have been removed from the store, so the following is not safe:
const unsafeData = store.lookup(claim);
0.0.3

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago