Skip to content
This repository has been archived by the owner on Feb 5, 2024. It is now read-only.

How to use Tabletop.fetch() for refreshing data? #113

Open
KokoDoko opened this issue Dec 29, 2015 · 6 comments
Open

How to use Tabletop.fetch() for refreshing data? #113

KokoDoko opened this issue Dec 29, 2015 · 6 comments

Comments

@KokoDoko
Copy link

After calling Tabletop.init(url, callback); my google drive data is fetched and displayed in a html page.
But at some point in the future, I need to reload the same data live, without refreshing the html page.
I presumed I could call Tabletop.fetch(); to do this but it seems that Tabletop.fetch(); causes a TypeError. Do I need to call init with the url and callback again?

@KokoDoko KokoDoko changed the title How check if Tabletop is already initialized, for reloading data? How to use Tabletop.fetch() for refreshing data? Dec 30, 2015
@GeorgeStrakhov
Copy link

plus one! would be very useful.

@ItsJoeTurner
Copy link

Did anyone figure this out?

@c2troie
Copy link

c2troie commented Sep 6, 2019

you can use setTimeout

@WebDevJL
Copy link

I did in this project.

I am currently making a npm package from the current of this repo.

@timhettler
Copy link

timhettler commented Apr 13, 2020

It appears that Tabletops internal Promise does not return tabletop. You must include a callback option, i.e.

function getSheetData(id) {
  return new Promise(function (resolve) {
    const options = {
      key: id,
      callback: (data, tabletop) => resolve({ data, tabletop });,
      simpleSheet: true,
    };
    Tabletop.init(options);
  });
}

@timhettler
Copy link

Here's a more detailed description of the issue:

If a custom callback isn't defined, it gets set to the resolve function of the Promise. (See line 173).

This issue is that Promise.resolve only accepts one argument, but the callback function is being apply-ed with two. (See line 449)

So: Tabletops callback API and the Promise API are incompatible.

I am willing to fix this issue, but the owner of this repo doesn't seem to be maintaining it anymore. Therefore, I'm providing this as forensic evidence to a future developer struggling with this issue. 🕵️

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants