Skip to content

Commit

Permalink
Fix action types
Browse files Browse the repository at this point in the history
  • Loading branch information
manzoorwanijk committed Nov 1, 2024
1 parent d820766 commit 68c6442
Showing 1 changed file with 56 additions and 48 deletions.
104 changes: 56 additions & 48 deletions packages/data/src/redux-store/metadata/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,151 +2,159 @@
* Returns an action object used in signalling that selector resolution has
* started.
*
* @param {string} selectorName Name of selector for which resolver triggered.
* @param {unknown[]} args Arguments to associate for uniqueness.
* @param selectorName Name of selector for which resolver triggered.
* @param args Arguments to associate for uniqueness.
*
* @return {{ type: 'START_RESOLUTION', selectorName: string, args: unknown[] }} Action object.
* @return Action object.
*/
export function startResolution( selectorName, args ) {
export function startResolution( selectorName: string, args: unknown[] ) {
return {
type: 'START_RESOLUTION',
selectorName,
args,
};
} as const;
}

/**
* Returns an action object used in signalling that selector resolution has
* completed.
*
* @param {string} selectorName Name of selector for which resolver triggered.
* @param {unknown[]} args Arguments to associate for uniqueness.
* @param selectorName Name of selector for which resolver triggered.
* @param args Arguments to associate for uniqueness.
*
* @return {{ type: 'FINISH_RESOLUTION', selectorName: string, args: unknown[] }} Action object.
* @return Action object.
*/
export function finishResolution( selectorName, args ) {
export function finishResolution( selectorName: string, args: unknown[] ) {
return {
type: 'FINISH_RESOLUTION',
selectorName,
args,
};
} as const;
}

/**
* Returns an action object used in signalling that selector resolution has
* failed.
*
* @param {string} selectorName Name of selector for which resolver triggered.
* @param {unknown[]} args Arguments to associate for uniqueness.
* @param {Error|unknown} error The error that caused the failure.
* @param selectorName Name of selector for which resolver triggered.
* @param args Arguments to associate for uniqueness.
* @param error The error that caused the failure.
*
* @return {{ type: 'FAIL_RESOLUTION', selectorName: string, args: unknown[], error: Error|unknown }} Action object.
* @return Action object.
*/
export function failResolution( selectorName, args, error ) {
export function failResolution(
selectorName: string,
args: unknown[],
error: Error | unknown
) {
return {
type: 'FAIL_RESOLUTION',
selectorName,
args,
error,
};
} as const;
}

/**
* Returns an action object used in signalling that a batch of selector resolutions has
* started.
*
* @param {string} selectorName Name of selector for which resolver triggered.
* @param {unknown[][]} args Array of arguments to associate for uniqueness, each item
* is associated to a resolution.
* @param selectorName Name of selector for which resolver triggered.
* @param args Array of arguments to associate for uniqueness, each item
* is associated to a resolution.
*
* @return {{ type: 'START_RESOLUTIONS', selectorName: string, args: unknown[][] }} Action object.
* @return Action object.
*/
export function startResolutions( selectorName, args ) {
export function startResolutions( selectorName: string, args: unknown[][] ) {
return {
type: 'START_RESOLUTIONS',
selectorName,
args,
};
} as const;
}

/**
* Returns an action object used in signalling that a batch of selector resolutions has
* completed.
*
* @param {string} selectorName Name of selector for which resolver triggered.
* @param {unknown[][]} args Array of arguments to associate for uniqueness, each item
* is associated to a resolution.
* @param selectorName Name of selector for which resolver triggered.
* @param args Array of arguments to associate for uniqueness, each item
* is associated to a resolution.
*
* @return {{ type: 'FINISH_RESOLUTIONS', selectorName: string, args: unknown[][] }} Action object.
* @return Action object.
*/
export function finishResolutions( selectorName, args ) {
export function finishResolutions( selectorName: string, args: unknown[][] ) {
return {
type: 'FINISH_RESOLUTIONS',
selectorName,
args,
};
} as const;
}

/**
* Returns an action object used in signalling that a batch of selector resolutions has
* completed and at least one of them has failed.
*
* @param {string} selectorName Name of selector for which resolver triggered.
* @param {unknown[]} args Array of arguments to associate for uniqueness, each item
* is associated to a resolution.
* @param {(Error|unknown)[]} errors Array of errors to associate for uniqueness, each item
* is associated to a resolution.
* @return {{ type: 'FAIL_RESOLUTIONS', selectorName: string, args: unknown[], errors: Array<Error|unknown> }} Action object.
* @param selectorName Name of selector for which resolver triggered.
* @param args Array of arguments to associate for uniqueness, each item
* is associated to a resolution.
* @param errors Array of errors to associate for uniqueness, each item
* is associated to a resolution.
* @return Action object.
*/
export function failResolutions( selectorName, args, errors ) {
export function failResolutions(
selectorName: string,
args: unknown[],
errors: ( Error | unknown )[]
) {
return {
type: 'FAIL_RESOLUTIONS',
selectorName,
args,
errors,
};
} as const;
}

/**
* Returns an action object used in signalling that we should invalidate the resolution cache.
*
* @param {string} selectorName Name of selector for which resolver should be invalidated.
* @param {unknown[]} args Arguments to associate for uniqueness.
* @param selectorName Name of selector for which resolver should be invalidated.
* @param args Arguments to associate for uniqueness.
*
* @return {{ type: 'INVALIDATE_RESOLUTION', selectorName: string, args: any[] }} Action object.
* @return Action object.
*/
export function invalidateResolution( selectorName, args ) {
export function invalidateResolution( selectorName: string, args: unknown[] ) {
return {
type: 'INVALIDATE_RESOLUTION',
selectorName,
args,
};
} as const;
}

/**
* Returns an action object used in signalling that the resolution
* should be invalidated.
*
* @return {{ type: 'INVALIDATE_RESOLUTION_FOR_STORE' }} Action object.
* @return Action object.
*/
export function invalidateResolutionForStore() {
return {
type: 'INVALIDATE_RESOLUTION_FOR_STORE',
};
} as const;
}

/**
* Returns an action object used in signalling that the resolution cache for a
* given selectorName should be invalidated.
*
* @param {string} selectorName Name of selector for which all resolvers should
* be invalidated.
* @param selectorName Name of selector for which all resolvers should
* be invalidated.
*
* @return {{ type: 'INVALIDATE_RESOLUTION_FOR_STORE_SELECTOR', selectorName: string }} Action object.
* @return Action object.
*/
export function invalidateResolutionForStoreSelector( selectorName ) {
export function invalidateResolutionForStoreSelector( selectorName: string ) {
return {
type: 'INVALIDATE_RESOLUTION_FOR_STORE_SELECTOR',
selectorName,
};
} as const;
}

0 comments on commit 68c6442

Please sign in to comment.