Created
July 23, 2020 21:31
-
-
Save gtsafas/851d684f5c12864ea84e1813f96306da to your computer and use it in GitHub Desktop.
This file contains 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
const saveSnapshotToServer = async (snapshot) => { | |
// async code here. | |
// Send a snapshot to the server, store it locally somewhere, etc. | |
} | |
const overrideCallback = (Provider) => { | |
// Extend default behavior | |
class MyOverride extends Provider { | |
async getSnapshot() { | |
// Call super to access vanilla platform behavior | |
const snapshot = await super.getSnapshot(); | |
// Perform any additional logic needed | |
const modifiedSnapshot = { ...snapshot, answer: 42 } | |
await saveSnapshotToServer(modifiedSnapshot); | |
return modifiedSnapshot; | |
} | |
} | |
// Return instance with methods to be consumed by Platform | |
return new MyOverride(); | |
}; | |
fin.Platform.init({ overrideCallback }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment