Callbacks
The optional JavaScript callback functions enables developers to react on events fired by FSI Image Twins.
Refer to the appropriate chapter to learn how to implement callbacks.
The following callback functions can be used:
onCardUncovered
onCardUncovered()
Called when one card is uncovered.
instance.addListener('onCardUncovered', () => {
// one card uncovered
doReallyGoodThings()
})
Example
onCardsCovered
onCardsCovered()
Called when all cards are covered.
instance.addListener('onCardsCovered', () => {
// all cards covered
doReallyGoodThings()
})
Example
onCardsUncovered
onCardsUncovered()
Called when all cards are uncovered.
instance.addListener('onCardsUncovered', () => {
// all cards uncovered
doReallyGoodThings()
})
Example
onDestroy
onDestroy()
Called as soon as the viewer is destroyed.
instance.addListener('onDestroy', () => {
// instance is destroyed
doReallyGoodThings()
})
Example
onGameEnd
onGameEnd(stats)
Called once after the game is finished.
instance.addListener('onGameEnd', (stats) => {
// game is finished
myFunc(stats)
})
Example
onGameStart
onGameStart(totalCards)
Called once after all cards have appeared.
instance.addListener('onGameStart', (totalCards) => {
// all cards have appeared
myFunc(totalCards)
})
Example
onInit
onInit(parameters)
Called as soon as the viewer is initialized.
instance.addListener('onInit', (parameters) => {
// viewer initialized
myFunc(parameters)
})
Example
onPairFound
onPairFound(stats, byChance)
Called each time a matching pair is found.
instance.addListener('onPairFound', (stats, byChance) => {
// game is finished
myFunc(stats, byChance)
})
Example
onSkinChanged
onSkinChanged(currentSkin, beforeSkin)
Called when the skin is changed.
instance.addListener('onSkinChanged', (currentSkin, beforeSkin) => {
// skin is changed
myFunc(currentSkin, beforeSkin)
})
Example