]>
Commit | Line | Data |
---|---|---|
1 | --- title: /api.html | |
2 | --- description: API Notation | |
3 | # API Notation | |
4 | ||
5 | The following document attempts to define a legend for easy specification of APIs for components. Any suggestions to improve are welcome. | |
6 | ||
7 | ``` | |
8 | NameOfClass.WithPossibleNamespace | |
9 | + class property | |
10 | - instance property | |
11 | ~> listened events (socket) | |
12 | +> listened events (class/module) | |
13 | -> listened events (instance) | |
14 | <~ dispatched events (socket) | |
15 | <+ dispatched events(class/module) | |
16 | <- dispatched events (instance) | |
17 | :: class method | |
18 | # instance method | |
19 | ||
20 | Other symbols | |
21 | => returns | |
22 | ->() callback return | |
23 | [xx] optional | |
24 | <xx> data type | |
25 | ||
26 | Recommended order: class first, then sockets, then instance. Internally: Properties, events, methods. | |
27 | ||
28 | // Anything after two forward slashes is a comment | |
29 | ``` | |
30 | ||
31 | Here's an example of usage | |
32 | ||
33 | ``` | |
34 | HypotheticalModule | |
35 | +staticProperty <String> | |
36 | +anotherStaticProperty <Boolean> | |
37 | ::toggleAnotherStaticProperty() | |
38 | ::setStaticProperty(newValue <String>) | |
39 | -instanceProperty <Number> | |
40 | -anotherInstanceProperty <String> | |
41 | #instanceMethodSync([optionalParameter]<Boolean>) => resultOfCall <String> | |
42 | #instanceMethodAsync(someValue <Number>, [callback] <Function>) ->(error <String|null>, result <Number|null>) | |
43 | ``` | |
44 | ||
45 | Here's another example but with events. | |
46 | ||
47 | ``` | |
48 | EventHypotheticalClass | |
49 | +>AnotherClass<+staticEventToListen(eventData <PredefinedObject>) | |
50 | <+staticEventDispatched(someData <SomeData>) | |
51 | ~>listenedSocketEvent(eventData <SomeObject>) | |
52 | <~dispatchedSocketEvent(eventData <BlaBla>) | |
53 | ->AnotherClass<-instanceEventToListen(eventData <Object>) | |
54 | <-instanceEventDispatched(specificDataType <DefinedObject>) | |
55 | ``` |