UNPKG

@360works/fmpromise

Version:
25 lines (21 loc) 698 B
interface FileMaker { PerformScript(script:string, parameter:string):string PerformScriptWithOption(script:string, parameter:string, option:number): string } declare global { interface Window { FileMaker: FileMaker } } const FMProxy:Promise<FileMaker> = new Promise((resolve, reject) => { let triesLeft = 100; const pollingId = window.setInterval(() => { // noinspection JSUnresolvedVariable,JSUnresolvedFunction if (window.FileMaker) { window.clearInterval(pollingId); resolve(window.FileMaker); } else if (!triesLeft--) { window.clearInterval(pollingId); reject('No window.FileMaker object was loaded after polling timeout.'); } }, 10); }) export default FMProxy;