@triplit/client
Version:
39 lines • 1.05 kB
JavaScript
/**
* Returns the disabled state for a subscription when enabled = false
*/
export function getDisabledSubscriptionState() {
return {
results: undefined,
fetching: false,
fetchingLocal: false,
fetchingRemote: false,
error: undefined,
};
}
/**
* Returns the initial loading state for a subscription when enabled = true
*/
export function getInitialSubscriptionState() {
return {
results: undefined,
fetching: true,
fetchingLocal: true,
fetchingRemote: false,
error: undefined,
};
}
/**
* Checks if a subscription should be enabled based on options
*/
export function isSubscriptionEnabled(options) {
return options?.enabled !== false;
}
/**
* Returns the appropriate initial state based on whether the subscription is enabled
*/
export function getInitialState(options) {
return isSubscriptionEnabled(options)
? getInitialSubscriptionState()
: getDisabledSubscriptionState();
}
//# sourceMappingURL=subscription-utils.js.map