Skip to content

Classes

AdamJames edited this page Feb 25, 2017 · 8 revisions

Events()

An event-emitter base class.

Methods

Both on and once also accept an array containing event names instead of a single event.

  • on(event, callback, once) adds an event handler for event. When triggered, callback is called.
  • once(event, callback) calls on with once set to true, which means callback will only be executed once.
  • emit(name, data) dispatches an event calling any respective handler's callback with data.
Attributes
  • __handlers a table containing event handlers.

Cache([discriminator])

A storage class with various object-management functions. discriminator is optional and defaults to id.

Methods
  • add(object) adds an object if no object with same discriminator is found.
  • remove(thing) removes an object, thing can be an object or a string.
  • getAll(key, value) returns a table containing all objects where object[key] == value.
  • get(key, value) same as previous one but returning the first object found.
Attributes
  • discriminator string defining what key is used for discrimination.

Route(base, ...)

Used for REST requests.

  • base a string to be formatted off given arguments.

rest(client)

A REST management class.

Methods
  • request(route[, data, method]) performs a request based on given values.
  • route a Route object.
  • data an object.
  • method a string representing what http method to use, defaults to GET.

Socket(client)

A WebSocket management class.

Methods
Clone this wiki locally