diff options
| author | Rubén Beltran del Río <954000-rbdr@users.noreply.gitlab.com> | 2021-07-06 08:35:59 +0000 |
|---|---|---|
| committer | Rubén Beltran del Río <954000-rbdr@users.noreply.gitlab.com> | 2021-07-06 08:35:59 +0000 |
| commit | 657de3fa00666ca71ed15f76deaba4e7ad2950c8 (patch) | |
| tree | be13ca3ba80b353c737a7c03429e03bbfc7f04e6 /reference/api_notation.md | |
| parent | 9739ae469545d22e1f5343c020acd843117d2bfc (diff) | |
Update reference/api_notation.md
Diffstat (limited to 'reference/api_notation.md')
| -rw-r--r-- | reference/api_notation.md | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/reference/api_notation.md b/reference/api_notation.md new file mode 100644 index 0000000..f4d7c11 --- /dev/null +++ b/reference/api_notation.md @@ -0,0 +1,53 @@ +# API Notation + +The following document attempts to define a legend for easy specification of APIs for components. Any suggestions to improve are welcome. + +``` +NameOfClass.WithPossibleNamespace + + class property + - instance property + ~> listened events (socket) + +> listened events (class/module) + -> listened events (instance) + <~ dispatched events (socket) + <+ dispatched events(class/module) + <- dispatched events (instance) + :: class method + # instance method + +Other symbols + => returns +->() callback return +[xx] optional +<xx> data type + +Recommended order: class first, then sockets, then instance. Internally: Properties, events, methods. + +// Anything after two forward slashes is a comment +``` + +Here's an example of usage + +``` +HypotheticalModule + +staticProperty <String> + +anotherStaticProperty <Boolean> + ::toggleAnotherStaticProperty() + ::setStaticProperty(newValue <String>) + -instanceProperty <Number> + -anotherInstanceProperty <String> + #instanceMethodSync([optionalParameter]<Boolean>) => resultOfCall <String> + #instanceMethodAsync(someValue <Number>, [callback] <Function>) ->(error <String|null>, result <Number|null>) +``` + +Here's another example but with events. + +``` +EventHypotheticalClass + +>AnotherClass<+staticEventToListen(eventData <PredefinedObject>) + <+staticEventDispatched(someData <SomeData>) + ~>listenedSocketEvent(eventData <SomeObject>) + <~dispatchedSocketEvent(eventData <BlaBla>) + ->AnotherClass<-instanceEventToListen(eventData <Object>) + <-instanceEventDispatched(specificDataType <DefinedObject>) +``` |