cacheCleared

Updated:

Allows an extension to watch for cache clearing within a specified route and then respond.

Description

Responses to requestExtensionData and requestPlatformData are stored in a shared cache between all extensions. Tecton provides two methods to work with the cache: clearCache for clearing the cache and notifying others, and cacheCleared which enables an extension to be notified when the cache for a route is cleared. cacheCleared takes a string parameter that is the route you want to observe for changes in the cache, and a callback to fire when changes are detected. It also returns an unsubscribe function that, when called, stops listening for changes on that route.

Signature

tecton.sources.cacheCleared(route: string, callback: function): () => void;

Usage

Listen for cache clears on account routes.

const unsubscribe = tecton.sources.cacheCleared('/api/accounts', () => {
    console.log('Account cache was cleared, refreshing data...');
    refreshAccountData();
});

Later, stop listening.

unsubscribe();

Additional Information

When using the cacheCleared source, there are important details to keep in mind.

Route Specificity

When using clearCache, pass the most general routes that have been affected. Any specific routes that start with the passed string will also be cleared and notified. For example, clearCache('/account') will notify someone who has subscribed using cacheCleared('/account/1').

Parameters

route
callback

Release Notes

Tecton
0.19.0

Platform Support

UUX
Config