From 3ebf9bf5468fa178da1dc55c8f340ade17cf6d98 Mon Sep 17 00:00:00 2001 From: Jeremy Kahn Date: Tue, 1 Jan 2019 11:22:21 -0600 Subject: [PATCH] Refactor Farmhand constructor --- src/Farmhand.js | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/src/Farmhand.js b/src/Farmhand.js index 5b836a8d7..d52681447 100644 --- a/src/Farmhand.js +++ b/src/Farmhand.js @@ -46,6 +46,18 @@ const { GROWN } = cropLifeStage; */ export default class Farmhand extends Component { + handlers = {}; + + localforage = localforage.createInstance({ + name: 'farmhand', + // NOTE: This should probably be determined by the package version + // instead of being hardcoded. + version: 1.0, + description: 'Persisted game data for Farmhand', + }); + + notificationSystemRef = createRef(); + /** * @member farmhand.Farmhand#state * @type {farmhand.state} @@ -68,23 +80,12 @@ export default class Farmhand extends Component { constructor() { super(...arguments); - this.notificationSystemRef = createRef(); - const handlers = (this.handlers = {}); - // Bind event handlers Object.keys(eventHandlers).forEach( - method => (handlers[method] = eventHandlers[method].bind(this)) + method => (this.handlers[method] = eventHandlers[method].bind(this)) ); this.initKeyHandlers(); - - this.localforage = localforage.createInstance({ - name: 'farmhand', - // NOTE: This should probably be determined by the package version - // instead of being hardcoded. - version: 1.0, - description: 'Persisted game data for Farmhand', - }); } /**