Manager.html 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5. <title>The source code</title>
  6. <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
  7. <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
  8. <style type="text/css">
  9. .highlight { display: block; background-color: #ddd; }
  10. </style>
  11. <script type="text/javascript">
  12. function highlight() {
  13. document.getElementById(location.hash.replace(/#/, "")).className = "highlight";
  14. }
  15. </script>
  16. </head>
  17. <body onload="prettyPrint(); highlight();">
  18. <pre class="prettyprint lang-js"><span id='Ext-state-Manager'>/**
  19. </span> * @class Ext.state.Manager
  20. * This is the global state manager. By default all components that are &quot;state aware&quot; check this class
  21. * for state information if you don't pass them a custom state provider. In order for this class
  22. * to be useful, it must be initialized with a provider when your application initializes. Example usage:
  23. &lt;pre&gt;&lt;code&gt;
  24. // in your initialization function
  25. init : function(){
  26. Ext.state.Manager.setProvider(new Ext.state.CookieProvider());
  27. }
  28. &lt;/code&gt;&lt;/pre&gt;
  29. * This class passes on calls from components to the underlying {@link Ext.state.Provider} so that
  30. * there is a common interface that can be used without needing to refer to a specific provider instance
  31. * in every component.
  32. * @singleton
  33. * @docauthor Evan Trimboli &lt;evan@sencha.com&gt;
  34. */
  35. Ext.define('Ext.state.Manager', {
  36. singleton: true,
  37. requires: ['Ext.state.Provider'],
  38. constructor: function() {
  39. this.provider = new Ext.state.Provider();
  40. },
  41. <span id='Ext-state-Manager-method-setProvider'> /**
  42. </span> * Configures the default state provider for your application
  43. * @param {Ext.state.Provider} stateProvider The state provider to set
  44. */
  45. setProvider : function(stateProvider){
  46. this.provider = stateProvider;
  47. },
  48. <span id='Ext-state-Manager-method-get'> /**
  49. </span> * Returns the current value for a key
  50. * @param {String} name The key name
  51. * @param {Object} defaultValue The default value to return if the key lookup does not match
  52. * @return {Object} The state data
  53. */
  54. get : function(key, defaultValue){
  55. return this.provider.get(key, defaultValue);
  56. },
  57. <span id='Ext-state-Manager-method-set'> /**
  58. </span> * Sets the value for a key
  59. * @param {String} name The key name
  60. * @param {Object} value The state data
  61. */
  62. set : function(key, value){
  63. this.provider.set(key, value);
  64. },
  65. <span id='Ext-state-Manager-method-clear'> /**
  66. </span> * Clears a value from the state
  67. * @param {String} name The key name
  68. */
  69. clear : function(key){
  70. this.provider.clear(key);
  71. },
  72. <span id='Ext-state-Manager-method-getProvider'> /**
  73. </span> * Gets the currently configured state provider
  74. * @return {Ext.state.Provider} The state provider
  75. */
  76. getProvider : function(){
  77. return this.provider;
  78. }
  79. });</pre>
  80. </body>
  81. </html>