From: Rubén Beltran del Río Date: Tue, 6 Jul 2021 08:35:59 +0000 (+0000) Subject: Update reference/api_notation.md X-Git-Url: https://git.r.bdr.sh/rbdr/txt/commitdiff_plain/657de3fa00666ca71ed15f76deaba4e7ad2950c8 Update reference/api_notation.md --- 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 + 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 + +anotherStaticProperty + ::toggleAnotherStaticProperty() + ::setStaticProperty(newValue ) + -instanceProperty + -anotherInstanceProperty + #instanceMethodSync([optionalParameter]) => resultOfCall + #instanceMethodAsync(someValue , [callback] ) ->(error , result ) +``` + +Here's another example but with events. + +``` +EventHypotheticalClass + +>AnotherClass<+staticEventToListen(eventData ) + <+staticEventDispatched(someData ) + ~>listenedSocketEvent(eventData ) + <~dispatchedSocketEvent(eventData ) + ->AnotherClass<-instanceEventToListen(eventData ) + <-instanceEventDispatched(specificDataType ) +```