Has Resources

Need to determine whether a resource exists, or whether a user has any resources? This is a good tool. Specify any HTML element with a slot to mark when it should show up. You may omit any slots you donโ€™t need.

<manifold-data-has-resource>
  <span slot="loading">Loadingโ€ฆ</span>
  <span slot="no-resource">User has no resources.</span>
  <span slot="has-resource">User has at least 1 resource!</span>
</manifold-data-has-resource>

Querying specific resource

Adding a label will let you see if a user has a specific resource or not. In this instance, no-resource will display if a user doesnโ€™t have that specific resource (they may still have resources provisioned other than the one specfied).

<manifold-data-has-resource label="my-resource">
  <span slot="loading">Loadingโ€ฆ</span>
  <span slot="no-resource">No label called โ€œmy-resourceโ€</span>
  <span slot="has-resource">โ€œmy-resourceโ€ found!</span>
</manifold-data-has-resource>

Polling interval

This will change the polling interval from 3000 ms (3 seconds, default) to 10000 ms (10 seconds):

<manifold-data-has-resource poll-interval="10000"></manifold-data-has-resource>

Pausing updates

By default, this component will subscribe to updates from the server and make periodic requests. To disable that, add the paused attribute:

<manifold-data-has-resource paused></manifold-data-has-resource>

Events

You can also programatically listen for events with the manifold-hasResource-load event. This is handy for redirecting in the case of resources not found:

document.addEventListener('manifold-hasResource-load', ({ detail }) => {
  console.log(detail);

  // {
  //   hasAnyResources: true,
  //   resourceLabel: 'my-resource',
  // }
});

Example

Loading No resources Has resources