@@ -15,16 +15,13 @@ Typings for Quenty's Binder (a Nevermore module)
1515``` ts
1616import Binder from " @rbxts/binder" ;
1717
18- class Disco implements Binder .BinderClass {
19- Instance: Part ;
20-
21- constructor (instance : Instance ) {
18+ class Disco {
19+ constructor (public readonly instance : Instance ) {
2220 assert (classIs (instance , " Part" ), " Invalid argument #1, Part expected" );
23- this .Instance = instance ;
2421 }
2522
2623 Update() {
27- this .Instance .BrickColor = BrickColor .random ();
24+ this .instance .BrickColor = BrickColor .random ();
2825 }
2926
3027 Destroy() {}
@@ -50,12 +47,12 @@ It is the same thing as you normally do in Binder from Luau.
5047** Function**
5148``` ts
5249const binder = new Binder (" Bird" , (inst ) => {
53- print (" Wow, a new bird!" , inst );
54- return {
55- Destroy() {
56- print (" Uh oh, the bird is gone!" );
57- },
58- };
50+ print (" Wow, a new bird!" , inst );
51+ return {
52+ Destroy() {
53+ print (" Uh oh, the bird is gone!" );
54+ },
55+ };
5956});
6057
6158binder .Start ();
@@ -65,40 +62,33 @@ binder.Start();
6562``` ts
6663// Create method is required
6764const binder = new Binder (" Hello" , {
68- Create(instance : Instance ) {
65+ Create(instance : Instance ) {
6966 print (" Wow a new bird!" , instance );
7067 return {
7168 Destroy() {
7269 print (" Uh oh, the bird is gone!" );
7370 },
7471 };
75- },
72+ },
7673});
7774```
7875
7976### Creating Binder from class prototype
8077
81- When you make Binder class, make sure it is implemented to ` Binder.BinderClass `
82-
83- * Make sure it has ` Destroy ` method. Binder won't able to construct a new class without it*
84-
85- ** Example** :
86- ``` ts
87- class DummyBinder implements BinderClass {
88- Destroy() {}
89- }
90- ```
91-
92- When creating Binder implemented class, make sure the first parameter
93- of the constructor function must be ` Instance ` type.
78+ When creating Binder base class, make sure the first parameter
79+ of the constructor function must be ` Instance ` type otherwise it will
80+ result a type mismatch error.
9481
9582** Example** :
9683``` ts
97- class DummyBinder implements BinderClass {
84+ class DummyBinder {
9885 constructor (instance : Instance ) {
9986 print (` ${instance .GetFullName ()} spawned! ` );
10087 }
101-
102- Destroy() {}
10388}
10489```
90+
91+ ## Destroying component
92+
93+ You may want to make either ` Destroy ` method either in ` lowercase ` or ` PascalCase `
94+ so that Binder can call it and automatically call the method.
0 commit comments