0.2.2 • Published 5 years ago

@destiny-plumbing/definitions v0.2.2

Weekly downloads
1
License
MIT
Repository
-
Last release
5 years ago

@destiny-plumbing/definitions

Note: consider this package to be very 'work-in-progress', an alpha. It's very likely that it won't work for your use case.

staleThenReinvalidate

Fetches, caches (in IndexedDB), and returns definitions. If there are already (potentially stale) cached definitions, they will be returned first while the Bungie.net manifest is checked for the latest version and updated definitions are returned.

Because state and then updated definitions can be returned, the callback can be called twice with two different sets of definitions. The last called is considered to be the latest definitions.

staleThenRevalidate(
  apiKey, // API key from Bungie.net
  language.code, // supported language from the manifest e.g. 'en'
  REQUIRED_DEFINITIONS, // array of definition tables. e.g. ['DestinyInventoryItemDefinition', 'DestinyObjectiveDefinition']
  (err, result) => {
    // Errors are currently not returned through the callback.
    if (err) {
      return handleError(err);
    }

    if (result && result.loading) {
      setStatus({ loading: true });
    }

    if (result && result.definitions) {
      setDefinitions(result.definitions);
    }
  }
);
0.2.2

5 years ago

0.2.1

5 years ago

0.2.0

5 years ago

0.1.2

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago