Last active
August 31, 2017 15:26
-
-
Save jecfish/87e1c957c0542bc6a81a195ccc5bc4ca to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// app/index.ts | |
import * as shuffle from 'lodash/fp/shuffle'; | |
import { Element as PolymerElement } from '@polymer/polymer/polymer-element'; | |
import '@polymer/polymer/lib/elements/dom-if'; // required because we are using dom-if in template | |
import * as view from './app.template.html'; | |
// component must be a class | |
export class MyApp extends PolymerElement { | |
cards: PolyTest.Card[]; | |
totalSeconds = 0; | |
timer: any = 0; | |
currentTime: PolyTest.Time = { hour: 0, minute: 0, second: 0 }; | |
isGameCompleted = false; | |
// Define a string template instead of a `<template>` element. | |
static get template() { | |
return view; | |
} | |
constructor() { | |
super(); | |
} | |
static get properties() { | |
// all the properties that need to show in template | |
return { | |
isGameCompleted: Boolean | |
}; | |
} | |
// lifecycle hook | |
ready() { | |
super.ready(); | |
this.cards = this.shuffleCards(); | |
} | |
private shuffleCards(): PolyTest.Card[] { | |
// ... logic to shuffle cards | |
return shuffle(list); | |
} | |
resetGame() { | |
// ... logic to reset game | |
} | |
// when click on any card first time, start the game timer | |
startGame() { | |
// no action if game is already started | |
if (this.timer) return; | |
// ... logic to start the game | |
} | |
stopGame() { | |
// ... logic to start the game | |
} | |
updateTime() { | |
// ... logic to update the time every second | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment