@rbxts/bin
TypeScript icon, indicating that this package has built-in type declarations

1.3.0 • Public • Published

@rbxts/bin

A super simple alternative to Maid.

Bin.Item

type Bin.Item =
	(() => unknown) // any function
	| RBXScriptConnection // an event connection
	| { destroy(): void } // object with destroy() or Destroy()
	| { Destroy(): void }; // i.e. Roblox Instances!

Bin.add

public add<T extends Bin.Item>(item: T): T;

Adds the item into the Bin, will return the item you passed in.

The returned value is useful for instances:

const part = this.bin.add(new Instance("Part"));
this.bin.add(part.Touched.Connect(() => print("Touched!")));

// later..

// both `part` and the connection are cleaned up!
this.bin.destroy();

Bin.destroy

public destroy(): void;

Destroys all items currently in the Bin:

  • Functions will be called
  • RBXScriptConnections will be disconnected
  • Objects will be .destroy()-ed

Bin.isEmpty

public isEmpty(): boolean;

Checks whether the Bin is empty.

Readme

Keywords

none

Package Sidebar

Install

npm i @rbxts/bin

Weekly Downloads

19

Version

1.3.0

License

MIT

Unpacked Size

8.72 kB

Total Files

6

Last publish

Collaborators

  • osyris