Skip to content

Releases: williamcotton/getit-and-react

checkIt, updateWith and cacheStore

Pre-release

Choose a tag to compare

@williamcotton williamcotton released this 07 May 07:44

checkIt

Compares the results from the retriever with the mock and lets you know if the interface has changed.

This is useful when using remote APIs. The remote function call can be compared to the mock to make sure that the response object is what is expected.

waitForIt.checkIt(function(error, response) {
  var checked = response.checked;
  if (checked) {
    console.log("It all checks out");
  }
});

updateWith

Calls all of the retriever function callbacks with a new object.

This is useful for when you need to trigger updates to the object from another source but callback all existing listening functions.

waitForIt.updateWith({
  currentTime: +new Date
});

cacheStore

Pass in a cacheStore that supports getItem(key), setItem(key, value), and removeItem(key).

Whenever the function is called it will return the last cached value.

Coming soon: time-based cache expiry, return-cache-and-continue-to-fetch.


waitForIt = getIt(waitForItFunction, waitForItMock, { cacheKey: "waitForIt", cacheStore: sessionStorage });