The Cape.JS defines a single global variable Cape.
It has some utility methods, such as
Overview of classes
The Cape.JS consists of following eight classes:
- Cape.Partial 1.3
- Cape.CollectionAgent 1.2
- Cape.ResourceAgent 1.2
These classes are defined as properties of the
The most basic class is
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.
Cape.MarkupBuilder are passed to the
render method of
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
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
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