All files / ima/page/manager PageManager.js

100% Statements 2/2
0% Branches 0/3
0% Functions 0/4
100% Lines 2/2
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84    8x                                                                                                                                                               8x  
import ns from '../../namespace';
 
ns.namespace('ima.page.manager');
 
/**
 * The page manager is a utility for managing the current controller and its
 * view.
 */
export default class PageManager {
  /**
	 * Initializes the page manager.
	 */
  init() {}
 
  /**
	 * Starts to manage the provided controller and its view. The manager
	 * stops the management of any previously managed controller and view.
	 *
	 * The controller and view will be initialized and rendered either into the
	 * UI (at the client-side) or to the response to send to the client (at the
	 * server-side).
	 *
	 * @param {(
	 *          string|
	 *          function(new: ima.controller.Controller, ...*)
	 *        )} controller The alias, namespace path, or constructor of the
	 *        controller to manage.
	 * @param {(
	 *          string|
	 *          function(
	 *            new: React.Component,
	 *            Object<string, *>,
	 *            ?Object<string, *>
	 *          )
	 *        )} view The alias, namespace path, or constructor of the page
	 *        view to manage.
	 * @param {{
	 *          onlyUpdate: (
	 *            boolean|
	 *            function(
	 *              (string|function(new: ima.controller.Controller, ...*)),
	 *              function(
	 *                new: React.Component,
	 *                Object<string, *>,
	 *                ?Object<string, *>
	 *              )
	 *            ): boolean
	 *          ),
	 *          autoScroll: boolean,
	 *          allowSPA: boolean,
	 *          documentView: ?function(new: AbstractDocumentView),
	 *          managedRootView: ?function(new: React.Component)
	 *        }} options The current route options.
	 * @param {Object<string, string>=} [params={}] The route parameters of the
	 *        current route.
	 * @return {Promise<{status: number, content: ?string, pageState: Object<string, *>
	 *         }>} A promise that will resolve to information about the rendered page.
	 *         The {@code status} will contain the HTTP status code to send to the
	 *         client (at the server side) or determine the type of error page
	 *         to navigate to (at the client side).
	 *         The {@code content} field will contain the rendered markup of
	 *         the page at the server-side, or {@code null} at the client-side.
	 */
  manage(controller, view, options, params = {}) {}
 
  /**
	 * Scrolls the viewport to the specified horizontal and vertical offset.
	 *
	 * This method has no effect at the server-side.
	 *
	 * @param {number=} [x=0] The horizontal offset to scroll to.
	 * @param {number=} [y=0] The vertical offset to scroll to.
	 */
  scrollTo(x = 0, y = 0) {}
 
  /**
	 * Finalization callback, called when the page manager is being discarded.
	 * This usually happens when the page is hot-reloaded at the client side.
	 */
  destroy() {}
}
 
ns.ima.page.manager.PageManager = PageManager;