Skip to content

Commit

Permalink
add StorageEvent type
Browse files Browse the repository at this point in the history
  • Loading branch information
idleberg committed Jun 15, 2024
1 parent 99da11f commit ed32e11
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/porridge-db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ export class PorridgeDB {
}

/**
* Observes value changes on a IndexedDB item
* Returns an array of IndexedDB's own enumerable string-keyed property `[key, value]` pairs
* @param {String} keyName
* @returns {boolean}
*
Expand Down Expand Up @@ -281,7 +281,7 @@ export class PorridgeDB {
* });
* ```
*/
public observe(keyName: string, callback: (payload: any) => void, targetOrigins: string[] = []): void {
public observe(keyName: string, callback: (payload: WebPorridge.StorageEvent) => void, targetOrigins: string[] = []): void {
if (typeof callback !== 'function') {
throw new TypeError('The callback argument is not a function');
}
Expand Down
2 changes: 1 addition & 1 deletion src/porridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ export class Porridge {
* });
* ```
*/
public observe(keyName: string, callback: (payload: any) => void, targetOrigins: string[] = []): void {
public observe(keyName: string, callback: (payload: WebPorridge.StorageEvent) => void, targetOrigins: string[] = []): void {
if (typeof callback !== 'function') {
throw new TypeError('The callback argument is not a function');
}
Expand Down
2 changes: 1 addition & 1 deletion src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ function didExpire(expires: string): boolean {
return expires && new Date(expires) <= new Date();
}

function eventDispatcher(eventName: string, payload: WebPorridge.CustomStorageEvent) {
function eventDispatcher(eventName: string, payload: WebPorridge.StorageEvent) {
try {
window.dispatchEvent(
new CustomEvent(eventName, {
Expand Down
2 changes: 1 addition & 1 deletion types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ declare namespace WebPorridge {
type: '@type';
}

type CustomStorageEvent = {
type StorageEvent = {
key?: string;
newValue: unknown;
oldValue: unknown;
Expand Down

0 comments on commit ed32e11

Please sign in to comment.