API Reference

Cape - Cape.Component - Cape.Partial - Cape.MarkupBuilder - Cape.DataStore - Cape.CollectionAgent - Cape.ResourceAgent - Cape.Router - Cape.RoutingMapper

The Cape object

The Cape.JS defines a single global variable Cape. It has some utility methods, such as extend, merge, etc.

Overview of classes

The Cape.JS consists of following eight classes:

These classes are defined as properties of the Cape object.

The most basic class is Cape.Component. You need to define a class extending it in order to create a web widget using Cape.JS. At least, instances of this class must have a method called render, which defines how the component should be rendered in HTML.

Cape.Partial is a class for partial components, namely the components that are include into another component. Partial components can not be mounted as a web widget directly.

Cape.MarkupBuilder is a class whose instances build virtual dom trees. Usually you don’t instantiate markup builders by yourself. Instances of Cape.MarkupBuilder are passed to the render method of component classes.

Cape.DataStore is a class to store and manipulate data, which is used by components to render themselves.

Cape.CollectionAgent has a role similar to the Cape.DataStore, but is much more powerful. Using it you can perform REST requests to the web resources through simple API.

Cape.ResourceAgent is a class to represent a particular resource on the web and performs REST manipulations on it.

Note that these two classes make use of the built-in Fetch API in order to send Ajax requests to the servers. They will help you to remove dependencies on jQuery from your applications.

If you want to create a single page application (SPA), you may need an instance of Cape.Router. After you start it, it continues to watch the changes of hash fragment of URL and mount components according to the routes (associations between hashes and components) which you defined in advance.

You have to call methods of Cape.RoutingMapper in order to define the routes. You will never instantiate it by youself, but will get its instance through the draw method of Cape.Router.