-
Notifications
You must be signed in to change notification settings - Fork 0
Client API
A zygo client instance can be accessed by importing the zygo module through SystemJS. This is how the client is initialized by zygo-server on page load, but if you see a use-case you can use the client as a stand-alone module:
System.import('zygo')
.then(function(zygo) {
...
});The zygo instance exposes the following public API:
-
zygo.route(routePath[, headers])
Matches the given routePath againstzygo.routes, runs the matched routes' handlers and renders the routes to thediv#__zygo-body-container__DOM element. If no routes are matched zygo falls back tozygo.routes.default. If this does not exist, an error is thrown. -
zygo.refresh()
Takes the currently visible routes (inzygo.context.curRoute.routes) and re-renders them with the currentzygo.context. The route handlers are not run again. This is useful if you want fine-grained control over context updates and re-renders. -
zygo.setMetadata()
Sets the page title tocontext.meta.title, pushes the current context to the HTML5 history API if possible and movescontext.loadRouteintocontext.curRoute. As this suggests, it is run by zygo at the end of aroute()transition.
The zygo instance exposes the following private API:
-
zygo._setContext(context) -
zygo._setRoutes(routes) -
zygo._setBundles(bundles)
Setters for the context, routes and bundles visible to zygo respectively. For more details on these, see the [https://github.com/zygo-io/zygo-server/wiki](zygo-server wiki). -
zygo._addLinkHandlers()
Sets up click handlers to automatically wrap anchor tags as route transitions if they correspond to a valid route. -
zygo._deserializeContext()
Deserializeszygo.contextif it has previously been serialized. See the [https://github.com/zygo-io/zygo-server/wiki](zygo-server wiki) for details.