base/chains.js

  1. "use strict";
  2. /**
  3. * @fileOverview The chains define the primary composition elements (functions) that determine the order of execution.
  4. *
  5. * @module base/chains
  6. * @requires dcl
  7. */
  8. var dcl = require( "dcl" );
  9. /**
  10. * @classDesc Chains define the primary composition elements (functions) that determine the order of execution.
  11. * @exports base/chains
  12. * @constructor
  13. */
  14. var Chains = dcl( null, {declaredClass : "base/chains"} );
  15. /**
  16. * The `close` method asks an object to shut itself down in a way that will allow it to be reopened, unlike the
  17. * [end method]{@link base/chains#end} which will call the destroy method which should make the object unusable, but also
  18. * devoid of all resources whereas `close` may still keep some resources open.
  19. *
  20. * | Heading 1 | Heading 2 | Heading 3 |
  21. * |-----------|-----------|-----------------|
  22. * | Bar | Food | This is a table |
  23. *
  24. * This uses the `before` chain which means the last one defined in the first one destroyed
  25. * @memberOf base/chains#
  26. * @name close
  27. * @see base/chains#open
  28. */
  29. dcl.chainBefore( Chains, "close" );
  30. /**
  31. * The `end` method will call the destroy method which should make the object unusable and
  32. * devoid of all resources, unlike the
  33. * [close method]{@link base/chains#close} asks an object to shut itself down in a way that will allow it to be reopened.
  34. *
  35. * This uses the `before` chain which means the last one defined in the first one destroyed
  36. * @memberOf base/chains#
  37. * @name end
  38. *
  39. * @example <caption>Add *this* to your application.properties.</caption>
  40. * {@lang bash}
  41. * foo=bar
  42. *
  43. */
  44. dcl.chainBefore( Chains, "end" );
  45. /**
  46. * Destroy is called by the end method and it is here that you should clean up after yourself. The difference between
  47. * `destroy` and [end]{@link base/chains#end} is the `end` is the verb that you raise on an object to ask it to go away
  48. * and `destroy` is where you actually do the work to clean up. Think of this as the counterpart of `constructor` yet
  49. * not called automatically.
  50. *
  51. * This uses the `before` chain which means the last one defined is the first one destroyed
  52. * @private
  53. * @memberOf base/chains#
  54. * @name destroy
  55. */
  56. dcl.chainBefore( Chains, "destroy" );
  57. /**
  58. * If you are using the open/close paradigm for an object that can kind of go dormant on {@link base/chains#close} and can be "reopened"
  59. * again later, here is where the "open" code will go.
  60. *
  61. * This used the `after` chain which means that the first one defined is the first one destroyed.
  62. *
  63. * @memberOf base/chains#
  64. * @name open
  65. * @see base/chains#close
  66. */
  67. dcl.chainAfter( Chains, "open" );
  68. module.exports = Chains;