@destiny-plumbing/definitions
v0.2.2
Published
**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.**
Downloads
6
Readme
@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);
}
}
);