Skip to content

Commit

Permalink
Refactor Farmhand constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremyckahn committed Jan 1, 2019
1 parent 09a5829 commit 3ebf9bf
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions src/Farmhand.js
Expand Up @@ -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}
Expand All @@ -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',
});
}

/**
Expand Down

0 comments on commit 3ebf9bf

Please sign in to comment.