1- # @rbxts/binder
1+ ## @rbxts/binder
22
3- Typings for Quenty's Binder (a Nevermore module), a module uses CollectionService to make tagged objects run by its own custom component classes
3+ Typings for Quenty's Binder (a Nevermore module)
44
55## Installation
66
7- ```
8- npm i @rbxts/binder
9- ```
7+ ** NPM** :
8+ ` npm i @rbxts/binder `
9+
10+ ** Yarn** :
11+ ` yarn add @rbxts/binder `
1012
1113## Usage
1214
@@ -17,10 +19,7 @@ class Disco implements Binder.BinderClass {
1719 Instance: Part ;
1820
1921 constructor (instance : Instance ) {
20- assert (
21- classIs (instance , " Part" ),
22- " Instance parameter must be Part instance" ,
23- );
22+ assert (classIs (instance , " Part" ), " Invalid argument #1, Part expected" );
2423 this .Instance = instance ;
2524 }
2625
@@ -34,9 +33,28 @@ class Disco implements Binder.BinderClass {
3433const discoBinder = new Binder (" Disco" , Disco );
3534discoBinder .Start ();
3635
37- game
38- .GetService (" RunService" )
39- .Heartbeat .Connect (() =>
40- discoBinder .GetAll ().forEach ((object ) => object .Update ()),
41- );
36+ // have some party!
37+ game .GetService (" RunService" ).Heartbeat .Connect (() => {
38+ for (const object of discoBinder .GetAll ()) {
39+ object .Update ();
40+ }
41+ });
42+ ```
43+
44+ ## Differences from the Luau version of Binder
45+
46+ ### Creating Binder class
47+
48+ When creating Binder implemented class, make sure the first parameter
49+ of the constructor function must be ` Instance ` type.
50+
51+ ** Example** :
52+ ``` ts
53+ class DummyClass implements BinderClass {
54+ constructor (instance : Instance ) {
55+ print (` ${instance .GetFullName ()} spawned! ` );
56+ }
57+
58+ Destroy() {}
59+ }
4260```
0 commit comments