UNPKG

yourrouter

Version:

A powerful router based on client-side routing.

26 lines (25 loc) 1.37 kB
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; import { GetRouteInfo } from '../../routes/application/GetRouteInfo'; export class ExecuteCurrentRouteCallback { constructor() { this.getRouteInfo = new GetRouteInfo(); } execute() { return __awaiter(this, void 0, void 0, function* () { const callback = this.getRouteInfo.callback(); if (callback === undefined) { const currentRoute = this.getRouteInfo.path(); throw new Error(`Error rendering a route. The callback for "${currentRoute}" is undefine. To fix add a callback for your route with "routerInstance.addRoute('/foo', callback)"`); } yield callback(); }); } }