From 20a075657f9c8133b65ea9cf6e8f1f633bc8a8e6 Mon Sep 17 00:00:00 2001 From: Dan Date: Mon, 16 Apr 2018 14:38:04 -0230 Subject: Documentation for various controllers and libs --- app/scripts/controllers/currency.js | 65 +++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) (limited to 'app/scripts/controllers/currency.js') diff --git a/app/scripts/controllers/currency.js b/app/scripts/controllers/currency.js index 36b8808aa..275219ce4 100644 --- a/app/scripts/controllers/currency.js +++ b/app/scripts/controllers/currency.js @@ -6,6 +6,22 @@ const POLLING_INTERVAL = 600000 class CurrencyController { + /** + * Controller responsible for managing data associated with the currently selected currency. + * + * @typedef {Object} CurrencyController + * @param {object} opts Overides the defaults for the initial state of this.store + * @property {array} opts.initState initializes the the state of the CurrencyController. Can contain an + * currentCurrency, conversionRate and conversionDate properties + * @property {string} currentCurrency A 2-4 character shorthand that describes a specific currency, currently + * selected by the user + * @property {number} conversionRate The conversion rate from ETH to the selected currency. + * @property {string} conversionDate The date at which the conversion rate was set. Expressed in in milliseconds + * since midnight of January 1, 1970 + * @property {number} conversionInterval The id of the interval created by the scheduleConversionInterval method. + * Used to clear an existing interval on subsequent calls of that method. + * + */ constructor (opts = {}) { const initState = extend({ currentCurrency: 'usd', @@ -19,30 +35,73 @@ class CurrencyController { // PUBLIC METHODS // + /** + * A getter for the currentCurrency property + * + * @returns {string} A 2-4 character shorthand that describes a specific currency, currently selected by the user + * + */ getCurrentCurrency () { return this.store.getState().currentCurrency } + /** + * A setter for the currentCurrency property + * + * @params {string} currentCurrency The new currency to set as the currentCurrency in the store + * + */ setCurrentCurrency (currentCurrency) { this.store.updateState({ currentCurrency }) } + /** + * A getter for the conversionRate property + * + * @returns {string} The conversion rate from ETH to the selected currency. + * + */ getConversionRate () { return this.store.getState().conversionRate } + /** + * A setter for the conversionRate property + * + * @params {number} conversionRate The new rate to set as the conversionRate in the store + * + */ setConversionRate (conversionRate) { this.store.updateState({ conversionRate }) } + /** + * A getter for the conversionDate property + * + * @returns {string} The date at which the conversion rate was set. Expressed in milliseconds since midnight of + * January 1, 1970 + * + */ getConversionDate () { return this.store.getState().conversionDate } + /** + * A setter for the conversionDate property + * + * @params {number} conversionDate The date, expressed in milliseconds since midnight of January 1, 1970, that the + * conversionRate was set + * + */ setConversionDate (conversionDate) { this.store.updateState({ conversionDate }) } + /** + * Updates the conversionRate and conversionDate properties associated with the currentCurrency. Updated info is + * fetched from an external API + * + */ async updateConversionRate () { let currentCurrency try { @@ -58,6 +117,12 @@ class CurrencyController { } } + /** + * Creates a new poll, using setInterval, to periodically call updateConversionRate. The id of the interval is + * stored at the controller's conversionInterval property. If it is called and such an id already exists, the + * previous interval is clear and a new one is created. + * + */ scheduleConversionInterval () { if (this.conversionInterval) { clearInterval(this.conversionInterval) -- cgit From 23acddf8f6fe4cb2d23e9b508c9b95f1f50fe32a Mon Sep 17 00:00:00 2001 From: Dan Date: Mon, 16 Apr 2018 19:45:27 -0230 Subject: @params -> @param fix --- app/scripts/controllers/currency.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'app/scripts/controllers/currency.js') diff --git a/app/scripts/controllers/currency.js b/app/scripts/controllers/currency.js index 275219ce4..6b166c151 100644 --- a/app/scripts/controllers/currency.js +++ b/app/scripts/controllers/currency.js @@ -1,4 +1,4 @@ -const ObservableStore = require('obs-store') + const ObservableStore = require('obs-store') const extend = require('xtend') // every ten minutes @@ -48,7 +48,7 @@ class CurrencyController { /** * A setter for the currentCurrency property * - * @params {string} currentCurrency The new currency to set as the currentCurrency in the store + * @param {string} currentCurrency The new currency to set as the currentCurrency in the store * */ setCurrentCurrency (currentCurrency) { @@ -68,7 +68,7 @@ class CurrencyController { /** * A setter for the conversionRate property * - * @params {number} conversionRate The new rate to set as the conversionRate in the store + * @param {number} conversionRate The new rate to set as the conversionRate in the store * */ setConversionRate (conversionRate) { @@ -89,7 +89,7 @@ class CurrencyController { /** * A setter for the conversionDate property * - * @params {number} conversionDate The date, expressed in milliseconds since midnight of January 1, 1970, that the + * @param {number} conversionDate The date, expressed in milliseconds since midnight of January 1, 1970, that the * conversionRate was set * */ -- cgit From e9ca7199ab9b63ef728fa93f8e98295c3096c553 Mon Sep 17 00:00:00 2001 From: Dan Date: Mon, 16 Apr 2018 21:23:29 -0230 Subject: Typo fixes, type fixes on the return clauses of the buyEthUrl and getPrefferedLangCode functions. --- app/scripts/controllers/currency.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app/scripts/controllers/currency.js') diff --git a/app/scripts/controllers/currency.js b/app/scripts/controllers/currency.js index 6b166c151..c23c7f616 100644 --- a/app/scripts/controllers/currency.js +++ b/app/scripts/controllers/currency.js @@ -10,7 +10,7 @@ class CurrencyController { * Controller responsible for managing data associated with the currently selected currency. * * @typedef {Object} CurrencyController - * @param {object} opts Overides the defaults for the initial state of this.store + * @param {object} opts Overrides the defaults for the initial state of this.store * @property {array} opts.initState initializes the the state of the CurrencyController. Can contain an * currentCurrency, conversionRate and conversionDate properties * @property {string} currentCurrency A 2-4 character shorthand that describes a specific currency, currently -- cgit From e80bd230b9bb6ac9ff05d7095f74dd2fd7ebb3af Mon Sep 17 00:00:00 2001 From: Dan Date: Wed, 18 Apr 2018 16:11:39 -0230 Subject: NO MIXED TABS AND SPACES --- app/scripts/controllers/currency.js | 46 ++++++++++++++++++------------------- 1 file changed, 23 insertions(+), 23 deletions(-) (limited to 'app/scripts/controllers/currency.js') diff --git a/app/scripts/controllers/currency.js b/app/scripts/controllers/currency.js index c23c7f616..37a19ff0d 100644 --- a/app/scripts/controllers/currency.js +++ b/app/scripts/controllers/currency.js @@ -6,12 +6,12 @@ const POLLING_INTERVAL = 600000 class CurrencyController { - /** - * Controller responsible for managing data associated with the currently selected currency. - * + /** + * Controller responsible for managing data associated with the currently selected currency. + * * @typedef {Object} CurrencyController - * @param {object} opts Overrides the defaults for the initial state of this.store - * @property {array} opts.initState initializes the the state of the CurrencyController. Can contain an + * @param {object} opts Overrides the defaults for the initial state of this.store + * @property {array} opts.initState initializes the the state of the CurrencyController. Can contain an * currentCurrency, conversionRate and conversionDate properties * @property {string} currentCurrency A 2-4 character shorthand that describes a specific currency, currently * selected by the user @@ -20,8 +20,8 @@ class CurrencyController { * since midnight of January 1, 1970 * @property {number} conversionInterval The id of the interval created by the scheduleConversionInterval method. * Used to clear an existing interval on subsequent calls of that method. - * - */ + * + */ constructor (opts = {}) { const initState = extend({ currentCurrency: 'usd', @@ -35,22 +35,22 @@ class CurrencyController { // PUBLIC METHODS // - /** - * A getter for the currentCurrency property - * - * @returns {string} A 2-4 character shorthand that describes a specific currency, currently selected by the user - * - */ + /** + * A getter for the currentCurrency property + * + * @returns {string} A 2-4 character shorthand that describes a specific currency, currently selected by the user + * + */ getCurrentCurrency () { return this.store.getState().currentCurrency } - /** - * A setter for the currentCurrency property - * - * @param {string} currentCurrency The new currency to set as the currentCurrency in the store - * - */ + /** + * A setter for the currentCurrency property + * + * @param {string} currentCurrency The new currency to set as the currentCurrency in the store + * + */ setCurrentCurrency (currentCurrency) { this.store.updateState({ currentCurrency }) } @@ -117,12 +117,12 @@ class CurrencyController { } } - /** - * Creates a new poll, using setInterval, to periodically call updateConversionRate. The id of the interval is + /** + * Creates a new poll, using setInterval, to periodically call updateConversionRate. The id of the interval is * stored at the controller's conversionInterval property. If it is called and such an id already exists, the * previous interval is clear and a new one is created. - * - */ + * + */ scheduleConversionInterval () { if (this.conversionInterval) { clearInterval(this.conversionInterval) -- cgit