ts/event/RouterEvent.ts - StructureJS

StructureJS

0.15.2

A class based utility library for building modular and scalable web platform applications. Features opt-in classes and utilities which provide a solid foundation and toolset to build your next project.

File: ts/event/RouterEvent.ts

  1. import BaseEvent from './BaseEvent';
  2.  
  3. /**
  4. * The RouterEvent is used in the {{#crossLink "Router"}}{{/crossLink}} class and gets passed to the callback in the {{#crossLink "Route"}}{{/crossLink}} class.
  5. *
  6. * @class RouterEvent
  7. * @extends BaseEvent
  8. * @param type {string} The type of event. The type is case-sensitive.
  9. * @param [bubbles=false] {boolean} Indicates whether an event is a bubbling event. If the event can bubble, this value is true; otherwise it is false.
  10. * Note: With event-bubbling you can let one Event subsequently call on every ancestor ({{#crossLink "EventDispatcher/parent:property"}}{{/crossLink}})
  11. * (containers of containers of etc.) of the {{#crossLink "DisplayObjectContainer"}}{{/crossLink}} that originally dispatched the Event, all the way up to the surface ({{#crossLink "Stage"}}{{/crossLink}}). Any classes that do not have a parent cannot bubble.
  12. * @param [cancelable=false] {boolean} Indicates whether the behavior associated with the event can be prevented. If the behavior can be canceled, this value is true; otherwise it is false.
  13. * @param [data=null] {any} Use to pass any type of data with the event.
  14. * @module StructureJS
  15. * @submodule event
  16. * @requires Extend
  17. * @requires BaseEvent
  18. * @constructor
  19. * @author Robert S. (www.codeBelt.com)
  20. */
  21. class RouterEvent extends BaseEvent
  22. {
  23. /**
  24. * The RouterEvent.CHANGE constant defines the value of the type property of an change route event object.
  25. *
  26. * @event CHANGE
  27. * @type {string}
  28. * @static
  29. */
  30. public static CHANGE:string = 'RouterEvent.change';
  31.  
  32. /**
  33. * The route that was matched against {{#crossLink "RouterEvent/routePattern:property"}}{{/crossLink}} property.
  34. *
  35. * @property route
  36. * @type {string}
  37. * @public
  38. */
  39. public route:string = null;
  40.  
  41. /**
  42. * The new URL to which the window is navigating.
  43. *
  44. * @property newURL
  45. * @type {string}
  46. * @public
  47. */
  48. public newURL:string = null;
  49.  
  50. /**
  51. * The previous URL from which the window was navigated.
  52. *
  53. * @property oldURL
  54. * @type {string}
  55. * @public
  56. */
  57. public oldURL:string = null;
  58.  
  59. /**
  60. * The route pattern that matched the {{#crossLink "RouterEvent/route:property"}}{{/crossLink}} property.
  61. *
  62. * @property routePattern
  63. * @type {string}
  64. * @public
  65. */
  66. public routePattern:string = null;
  67.  
  68. /**
  69. * An array containing the parameters captured from the Route.{{#crossLink "Route/match:method"}}{{/crossLink}}
  70. * being called with the {{#crossLink "RouterEvent/routePattern:property"}}{{/crossLink}} property.
  71. *
  72. * @property params
  73. * @type {Array.<string>}
  74. * @public
  75. */
  76. public params:Array<string> = [];
  77.  
  78. /**
  79. * A query object the represents the query string in the hash url.
  80. *
  81. * @property query
  82. * @type {any}
  83. * @public
  84. */
  85. public query:any = null;
  86.  
  87. constructor(type:string = RouterEvent.CHANGE, bubbles:boolean = false, cancelable:boolean = false, data:any = null)
  88. {
  89. super(type, bubbles, cancelable, data);
  90. }
  91.  
  92. }
  93.  
  94. export default RouterEvent;