Skip to content

Instantly share code, notes, and snippets.

@chubas
Last active August 29, 2015 14:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chubas/1b9bded64bf991aa951c to your computer and use it in GitHub Desktop.
Save chubas/1b9bded64bf991aa951c to your computer and use it in GitHub Desktop.

The following document attempts to define a legend for easy specification of APIs for components. Any suggestions to improve are welcome.

Class Members
   + 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.

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>)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment