Client namespace & classes

Client-side equivalent classes

Some server-side classes have client-side equivalents. These are put in the Alchemy.Client namespace.

A few examples include:

  • Alchemy.Client.Model
  • Alchemy.Client.Document
  • Alchemy.Client.Conduit
  • Alchemy.Client.Controller
  • ...

Where server-side classes mostly inherit from Alchemy.Base, client-side classes inherit from Alchemy.Client.Base

Methods & property getters added to client-side classes are also automatically added to the server-side equivalent, if those do not have an existing implementation already.

Client-side models & documents

Models are special: a client-side equivalent model class is automatically created for every model.

If you want to change these classes, you can't recreate them using Function.inherits, but you have to use the custom Model.getClass method.

The following example will add a title getter to the client-side ProjectVersion document class. Because there is no specific server-side implementation, this property will also be available on the server-side document class:

const ProjectVersion = Hawkejs.Model.getClass('ProjectVersion');

ProjectVersion.setDocumentProperty(function title() {
    return this.name.titleize();
});